0
write a programin php to print n numbers without using loop or a foreach statement .
3 Antworten
+ 3
use recursion :-D
<?php
function numbers($n,$max)
{
if ($n<=$max)
{
echo $n.", ";
numbers($n+1,$max);
}
else exit();
}
numbers(1,10);
?>
0
Hey there are lots of ways to print the n numbers using loop such as for loop ,do while ,while loop ,for each too.
I don't know how to code without using loops ??
Anyone here solve this
- 2
You are looking for the "for" loop
for ($i=1; $i <=10; $i++) {
echo $i;
}