Hi guys !
I've got a string. $myString = "Fox jumps over the lazy dog";
And now I need to convert this string into the array. So that each letter (including white space) would be a different ellement. For exapmle: $myArray [0] = "F"; $myArray [1] = "o"; $myArray [2] = "x"; $myArray [3] = " "; .. and so on
Please help me. I have been looking in PHP documentation but without success.
Thank You.
Try this. <?php $myString = "Fox jumps over the lazy dog"; for($i = 0, $count = strlen($myString); $i < $count; $i++) $myArray[] = substr($myString, $i, 1);
print_r($myArray); ?>
There is probably a better way, but this works.
Aaron
Thanks. It works !
Or you can just use $myString
$myString = "Fox jumps over the lazy dog";
for($i=0;$i<strlen($myString);$i++) { print($myString[$i]); }
/Staffan