这里有东西;还有,哦,仅此而已!"
我想用;
和,
所以处理后应该得到:
something here
and 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>';
更新了一个更新问题的答案:
Updated answer to an updated question:
<?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 中通过多个分隔符分割字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!