Back to Base32 class

Method str2bin

private string
str2bin
(mixed $str)
str2bin
Parameters
  • string $str The string you want to convert
Returns
  • string String of 0's and 1's
Class: Base32
Project: Joomla

Method str2bin - Source code

/**
 * str2bin
 *
 * Converts any ascii string to a binary string
 *
 * @param   string  $str  The string you want to convert
 *
 * @return  string  String of 0's and 1's
 */
private function str2bin($str)
{
    $chrs = unpack('C*', $str);
    return vsprintf(str_repeat('%08b', \count($chrs)), $chrs);
}