Something seems to be wrong with this function and I can't figure out
why it is failing. The error that it gives is; Invalid argument
supplied for foreach() .
function transposition($ words){
foreach($words as $word){
for($x=0;$x<str len($word)-1;$x++){
$results[] = substr($word, 0, $x) . $word[$x+1] . $word[$x] .
substr($word, $x+2, strlen($word));
}
}
return $results;
}
The way I call the function is:
echo(correct("o riginal"));
Do you see anything wrong?
Thanks,
Bryan
why it is failing. The error that it gives is; Invalid argument
supplied for foreach() .
function transposition($ words){
foreach($words as $word){
for($x=0;$x<str len($word)-1;$x++){
$results[] = substr($word, 0, $x) . $word[$x+1] . $word[$x] .
substr($word, $x+2, strlen($word));
}
}
return $results;
}
The way I call the function is:
echo(correct("o riginal"));
Do you see anything wrong?
Thanks,
Bryan
Comment