I'm expecting this to print from "Count 1" to "Count 9". But the $str variable is not updating inside the while loop. It just prints "Count 1" nine times. In my use-case it's not possible to initiate $str inside the while loop therefore I'm looking for a dynamic update of the $str var inside the while loop.
$p = 1;
$str = "Count {$p}";
while ( $p < 10 ) {
$p++;
echo $str . PHP_EOL;
}
while()loop to echo out those strings?sprintfto get that substituted with the current value of $p inside the loop …