我正在尝试逐个字符地分解字符串,但我遇到了特殊字符的麻烦。我目前正在使用以下功能:
<?php
$input = "Comment ça va?";
$array_input = str_split($input, 1);
print_r($array_input);
?>
这是输出:
Array (
[0] => C [1] => o [2] => m [3] => m [4] => e
[5] => n [6] => t [7] => [8] => � [9] => �
[10] => a [11] => [12] => v [13] => a [14] => ? )
我对换行符有同样的问题:
输入:
“Hé!
Oui?”
输出:
Array ( [0] => H [1] => � [2] => � [3] => ! [4] =>
[5] => [6] => O [7] => u [8] => i [9] => ? )
有人有这个问题的解决方案吗?非常感谢。