views:

46

answers:

1

Try this:

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

output:

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

The character you have is a fullwidth comma ( hex ff0c ), as well as a regular comma. Have you tried updating it to my version which accounts for it?

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

Output:

Array
(
    [0] => hei
    [1] => nihao
    [2] => a 
)
meder
In the other prior post you said you updated it to be like mine. Did you have it *exactly* like mine? If so paste the new exact version that I had please.
meder
I tried your code,and the output is not the same as yours.It's <pre>Array( [0] => hei,nihao,a)</pre>
Shore
*sigh*Can you update your post with my updated version so I can see? You may have made some mistake and missed something, there is a 'u' character after the regex that you may have missed if you copied it manually, which is why I want to see what you have *now*
meder
Done:)
Shore
Ok. Mine is still giving me the same result. What php version do you have? It's possible yours may not support the unicode inside the regex character set.
meder
And just curious, how did you generate that character in the first place? You're dealing with a language other than English?
meder
Yes,it's CJK character.I'm gonna give it up,by replace that special character.
Shore
What version of PHP? As much info as possible...
meder
PHP 5.2.5 (cli) (built: Nov 8 2007 23:18:51)
Shore