我正在寻找 js 中的等价物 'this is a string'.split('')
for PHP。
如果我尝试 $array = explode('', 'testing');
我得到一个错误 Warning: explode() [function.explode]: Empty delimiter in
还有其他方法吗?
最佳答案
如您的错误所示,explode
需要分隔符来拆分字符串。使用 str_split
相反:
$arr = str_split('testing');
输出
Array
(
[0] => t
[1] => e
[2] => s
[3] => t
[4] => i
[5] => n
[6] => g
)
关于php explode 所有字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9814375/