PHP:使用特殊字符爆炸 [英] PHP: Explode using special characters
问题描述
我正在处理从使用§"(分段符号)的Session抓取的长字符串,以对字符串的不同部分进行分组和划分.
I'm working on a long string grabbed from a Session that uses "§" (Section sign) to group and divide different parts of the string.
示例:"ArticleID |标题|日期§ArticleID |标题|日期§ArticleID |标题|日期"
Example: "ArticleID | Title | Date § ArticleID | Title | Date § ArticleID | Title | Date"
我想使用以下命令将其放入数组中:
explode("§",$str);
I want to put this into an array using:
explode("§",$str);
但是,由于某些原因,字符被完全忽略了.
However, for some reason the character is totally ignored.
我只是使用了一个不同的字符来代替此功能,但是为什么PHP不能识别它呢?
I have simply used a different character instead to get this working but why does PHP not recognise it?
推荐答案
检查文件编码.可以将该§分别以"\ xA7","\ xA7 \ x00"或"\ xC2 \ xA7"的形式传递给explode(),具体取决于PHP文件是分别编码为ASCII,UNICODE还是UTF-8.
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.
这篇关于PHP:使用特殊字符爆炸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!