0

尝试这个:

$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>';
exit();

输出:

<pre>Array
(
    [0] => hei,nihao,a
)
</pre>
4

1 回答 1

0

您拥有的字符是全角逗号(十六进制 ff0c)以及常规逗号。您是否尝试过将其更新到我的版本来解决这个问题?

<?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>';

输出:

Array
(
    [0] => hei
    [1] => nihao
    [2] => a 
)
于 2009-09-21T04:06:25.977 回答