so i undrestand a string is array of charachters so we can do something like this
$str = 'abc';
for ($i = 0; $i < strlen($str); $i++){
echo "$i -> $str[$i] <br /> ";
}
which results in
0 -> a
1 -> b
2 -> c
but why can't i do this process with foreach loop ?
$str = 'abc';
foreach($str as $k=>$v )
echo "$k -> $v <br /> ";
result would be
Warning: Invalid argument supplied for foreach()
this is not a practical question , im not trying to use foreach on string and i dont need another alternative solution like str_split just a theoretical question