$ch is a character.
I need to convert it into 2 numbers like that (example):
$ch = 'A' => ASCII code: 0x41
=> Binary: 0100 0001
=> {4, 1}
What is the easiest and fastest method to achieve this ?
You can use the
ord()function to get the ASCII value and thendecbinanddechexto convert it to binary and hex formatshttp://www.php.net/manual/en/function.ord.php
http://www.php.net/manual/en/function.decbin.php
http://www.php.net/manual/en/function.dechex.php