PHP: Explode using special characters

2019-02-17 13:18发布

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?

1条回答
我只想做你的唯一
2楼-- · 2019-02-17 13:40

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.

查看更多
登录 后发表回答