我们可以在
PHP中进行多次explode()吗?
例如,要这样做:
foreach(explode(" ",$sms['sms_text']) as $no) foreach(explode("&",$sms['sms_text']) as $no) foreach(explode(",",$sms['sms_text']) as $no)
一体化爆炸像这样:
foreach(explode('','&',',$sms['sms_text']) as $no)
最好的方法是什么?我想要的是在一行中的多个分隔符上拆分字符串.
如果您希望将字符串拆分为多个分隔符,则可能需要
原文链接:https://www.f2er.com/php/133651.htmlpreg_split
.
$parts = preg_split( '/(\s|&|,)/','This and&this and,this' ); print_r( $parts );
结果如下:
Array ( [0] => This [1] => and [2] => this [3] => and [4] => this )