PHP: Explode using special characters

被刻印的时光 ゝ 提交于 2019-12-01 03:03:31

问题


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:


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.



来源:https://stackoverflow.com/questions/1371216/php-explode-using-special-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!