如何在PHP中用多个分隔符分割字符串?
"something here ; and there, oh,that's all!"
我想用;
和分开,
因此处理后应该得到:
something hereand there
oh
that's all!
回答:
<?php$pattern = '/[;,]/';
$string = "something here ; and there, oh,that's all!";
echo '<pre>', print_r( preg_split( $pattern, $string ), 1 ), '</pre>';
对更新问题的更新答案:
<?php$pattern = '/[\x{ff0c},]/u';
//$string = "something here ; and there, oh,that's all!";
$string = 'hei,nihao,a ';
echo '<pre>', print_r( preg_split( $pattern, $string ), 1 ), '</pre>';
以上是 如何在PHP中用多个分隔符分割字符串? 的全部内容, 来源链接: utcz.com/qa/397724.html