<?php
function iterate($x){ //this is the function
for ($i = 0; $i <= 10; $i++){ //this is the loop procedure to iterate 10 times
echo $i; //it will show 0123456789 on the screen
}
}
$y = "xyz"; //variable declaration
echo iterate($y); //should be iterate xyz as much 10 times.
?>
wish to echo(print) xyz ten times using for loop inside the php function, the result not as expected. how to show the xyz iterate ten times.
echo $xwhich is the value you pass to the function.$i, which is the counter variable used in the loop. You want to echo the variable holding "xyz".echo $x;