String to Binary convert

This tool will help you to convert any string to binary.

Input string:

Convert String to Binary in PHP

PHP how to convert String to Binary?

function SitaPhpConvertStringToBinary($string)
{
    $characters = str_split($string);

    $binary = [];
    foreach ($characters as $character) {
        $data = unpack('H*', $character);
        $binary[] = base_convert($data[1], 16, 2);
    }

    return implode(' ', $binary);
}
$binary = SitaPhpConvertStringToBinary('sita.app');
//output: $binary = 1110011 1101001 1110100 1100001 101110 1100001 1110000 1110000
        

Convert Binary to String in PHP

PHP how to convert Binary to String?

function SitaPhpConvertBinaryToString($binary)
{
    $binaries = explode(' ', $binary);

    $string = null;
    foreach ($binaries as $binary) {
        $string .= pack('H*', dechex(bindec($binary)));
    }

    return $string;
}
$string = SitaPhpConvertBinaryToString('1110011 1101001 1110100 1100001 101110 1100001 1110000 1110000');
//output: $string = sita.app