0

write a programin php to print n numbers without using loop or a foreach statement .

31st Jul 2016, 9:03 AM
Surbhi Jain
Surbhi Jain - avatar
3 Respostas
+ 3
use recursion :-D <?php function numbers($n,$max) { if ($n<=$max) { echo $n.", "; numbers($n+1,$max); } else exit(); } numbers(1,10); ?>
1st Aug 2016, 6:32 PM
Seb
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
1st Aug 2016, 5:37 AM
Sajen "The Empathy"
Sajen "The Empathy" - avatar
- 2
You are looking for the "for" loop for ($i=1; $i <=10; $i++) { echo $i; }
31st Jul 2016, 11:04 AM
Nathan “Grimston” Pipes
Nathan “Grimston” Pipes - avatar