php爆炸所有字符

问题描述:

我正在寻找相当于 js 中的 'this is a string'.split('') for PHP.

I'm looking for the equivalent of what in js would be 'this is a string'.split('') for PHP.

如果我尝试 $array =explode('', 'testing'); 我得到一个错误 警告:explode() [function.explode]: Empty delimiter in

If I try $array = explode('', 'testing'); I get an error Warning: explode() [function.explode]: Empty delimiter in

还有其他方法可以做到这一点吗?

Is there another way to do this?

如您的错误所示,explode 需要一个分隔符来拆分字符串.使用 str_split 代替:

As indicated by your error, explode requires a delimiter to split the string. Use str_split instead:

$arr = str_split('testing');

输出

Array
(
    [0] => t
    [1] => e
    [2] => s
    [3] => t
    [4] => i
    [5] => n
    [6] => g
)