0

How can I make a circular loop using array?

I want to make a circular loop using array how can I do that can anyone help?

18th Jul 2016, 3:51 PM
Purohit Pratik
Purohit Pratik - avatar
4 Respuestas
0
u want to say a circle
23rd Jul 2016, 12:47 PM
Kamal Singh
Kamal Singh - avatar
0
U need to use % by array length: so u lock 🔒 loop
2nd Aug 2016, 5:23 PM
Eugen Stoliyarof
Eugen Stoliyarof - avatar
0
As Eugene said, you can use modulus. Here is and example that will echo 0 to 9 ten times for($i = 0; $i < 100; $i++) { echo $i%10; } To reference an array you could echo myArray[$i]; inside the loop.
2nd Sep 2016, 3:43 PM
AccountKiller
- 1
I suggest u take a look at circular queues of C++. Apply the same logic. Hope it helps
5th Aug 2016, 11:45 AM
Sumitabha Banerjee
Sumitabha Banerjee - avatar