I want to pass to a new line after detecting the number in the string. So I want output to be:
nameone
2 nametwo
3 namethree
here is the code that I am running in php:
$str="nameone 2 nametwo 3 namethree";
for ($i=0;$i<=strlen($str)-1;$i++){
$char=$str[$i];
if (is_int($char)){
echo "\n".$char;
}
else if (!is_int($char)){
echo $char;
}
}
however the output is nameone 2 name two 3 namethree. What am I doing wrong?