PHP: Explode using special characters

explodePHPspecial characters

I'm working on a long string grabbed from a Session that uses "§" (Section sign) to group and divide different parts of the string.

Example: "ArticleID | Title | Date § ArticleID | Title | Date § ArticleID | Title | Date"

I want to put this into an array using:
explode("§",$str);

However, for some reason the character is totally ignored.

I have simply used a different character instead to get this working but why does PHP not recognise it?

Best Answer

Check the file encoding. This § can be being passed to explode() as "\xA7", "\xA7\x00" or "\xC2\xA7" depending if the PHP file is encoded as ASCII, UNICODE or UTF-8 respectively.