I am trying to explode a string on what looks like to be a null character.
This is what is what I am using:
$exp = explode('\x00', $bin);.
Though this does not work. However, if I do
$exp = explode($bin, $bin); (where character 5 of
$bin is this character I want to explode on) it works fine.
If I do
var_dump($bin) It shows me square block with a question mark in it (), and in the view source I get:
Can anyone tell me what the best way would be to explode on this character? or even if it is the null character (which according to ascii tables it is, unless I am reading it all wrong).
Try double quotes:
$exp = explode("\x00", $bin);
Alternatively, capture the equivalent ASCII character code and pass it using chr.
$char = ord($bin); // Replace this with the actual number returned from ord $exp = explode(chr($char), $bin);
This latter example eliminates the possibility that it might not actually be a null character if you haven’t already determined it.