I have a rather large string that I need to split into individual characters.
I cannot figure out how to do this realitively easy thing. Any help would be appericated.
Thanks
$str="asjdlhdakjfhdfsadf";
for($i=0;$i<strlen($str);$i++) { $chr[] = substr($str,$i,1); }
🙂
There is no need to loop through the string when strings can be treated as arrays
$string = "abcdefg";
print $string[2]; This will print 'c'.
print $string[0] This will print 'a'
chunk_split() is also useful here