PHP 分割问题
我正在尝试使用(并且我已经尝试过) preg_split() 和 split() ,但这些都不适合我。以下是尝试和输出。
preg_split("^", "ItemOne^ItemTwo^Item.Three^");
//output - null or false when attempting to implode() it.
preg_split("\^", "ItemOne^ItemTwo^Item.Three^");
//output - null or false when attempting to implode() it. Attempted to escape the needle.
//SAME THING WITH split().
感谢您的帮助... 克里斯蒂安·斯图尔特
I am trying to use (and I've tried both) preg_split() and split() and neither of these have worked for me. Here are the attempts and outputs.
preg_split("^", "ItemOne^ItemTwo^Item.Three^");
//output - null or false when attempting to implode() it.
preg_split("\^", "ItemOne^ItemTwo^Item.Three^");
//output - null or false when attempting to implode() it. Attempted to escape the needle.
//SAME THING WITH split().
Thanks for your help...
Christian Stewart
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
split
已弃用。您应该使用explode
$arr =explode('^', "ItemOne^ItemTwo^Item.Three^");
split
is deprecated. You should useexplode
$arr = explode('^', "ItemOne^ItemTwo^Item.Three^");
尝试一下
,因为您的搜索模式不是正则表达式。
Try
since your search pattern isn't a regex.
您确定您不只是在寻找
explode
吗?爆炸('^', 'ItemOne^ItemTwo^Item.Three^');
Are you sure you're not just looking for
explode
?explode('^', 'ItemOne^ItemTwo^Item.Three^');
由于您正在使用
preg_split
您正在尝试按给定的正则表达式拆分字符串。扬抑符 (^) 是正则表达式元字符,因此在您的示例中不起作用。顺便说一句: preg_split 是 split 的替代方案,但并未弃用。
Since you are using
preg_split
you are trying to split the string by a given regular expresion. The circumflex (^) is a regular expression metacharacter and therefore not working in your example.btw: preg_split is an alternative to split and not deprecated.