为什么用多字节标点符号分割时会出现额外的空行?
试试这个:
$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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您拥有的字符是全角逗号(十六进制 ff0c )以及常规逗号。您是否尝试过将其更新到我的版本?
输出:
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?
Output: