<?php
$string = '
1
2
3
4';
$tags = preg_split('/[;:, \rn]+/', $string);
foreach ($tags as $to_x)
{
echo strlen($to_x)."</br>";
}
?>
输出错误
用新行将其分解,但不显示正确的 strlen 。
输出
1
2
2
2
实际输出应该是
1
1
1
1
我哪里错了???
最佳答案
'/[;:,\r\n]+/'
确保它是\n
关于php preg_split 按新行爆炸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22434188/