hex2bin 


string apg

DECODES  hexadecimally  to an encoded  binary  STRING.

The hex2bin is inverse function of the hex2bin function.




This function does NOT convert a hexadecimal number to a binary number.



<?php

str hex2bin 
str $data )


where,

$data The hexadecimal representation of data

?>

  1 EXERCISE   

<?php

$hex01 
'47efbfbd2e70efbfbdefbfbd381f5f0eefbfbdefbfbd';

$hex2bin01 hex2bin($hex01);

echo 
$hex2bin01;

?>

 RESULT   

HEXADECIMAL REPRESENTATION:
'47efbfbd2e70efbfbdefbfbd381f5f0eefbfbdefbfbd'

BINARY DATA:
'G�.p��8_��'


  2 EXERCISE   

<?php

$hex02 
'313031303131303130313131303030';

$hex2bin02 hex2bin($hex02);

echo 
$hex2bin02;

?>

 RESULT   

HEXADECIMAL REPRESENTATION:
'313031303131303130313131303030'

BINARY DATA:
'101011010111000'


  3 EXERCISE   

<?php

$hex03 
'4561737920636f6d652c206561737920676f2e';

$hex2bin03 hex2bin($hex03);

echo 
$hex2bin03;

?>

 RESULT   

HEXADECIMAL REPRESENTATION:
'4561737920636f6d652c206561737920676f2e'

BINARY DATA:
'Easy come, easy go.'


  4 EXERCISE   

<?php

var_dump
(bin2hex(hex2bin('012345')) == '012345');
echo 
'<br><br>';
var_dump(bin2hex(hex2bin('abc123')) == 'abc123');
echo 
'<br><br>';
var_dump(bin2hex(hex2bin('123abc')) == '123abc');
echo 
'<br><br>';
var_dump(bin2hex(hex2bin('FFFFFF')) == 'ffffff');

?>

  5 EXERCISE   

<?php

var_dump
(hex2bin('SATOR'));
ECHO 
'<br><br>';
var_dump(hex2bin('ROTAS'));

?>