php explode all characters [duplicate]

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

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

Is there another way to do this?


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

$arr = str_split('testing');

Output

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

Use the str_split function.

$array = str_split( 'testing');

$string = "TEST";

echo $string[0];  // This will display T

There is no need to explode it