开发者

PHP explode on null character

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('\x0开发者_运维百科0', $bin);.

Though this does not work. However, if I do $exp = explode($bin[5], $bin); (where character 5 of $bin is this character I want to explode on) it works fine.

If I do var_dump($bin[5]) 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).

Thanks


Try double quotes:

$exp = explode("\x00", $bin);

Alternatively, capture the equivalent ASCII character code and pass it using chr.

$char = ord($bin[5]);

// 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜