Kaiwen Kaiwen - 3 years ago 142
PHP Question

php - Is it possible to have a function that can generate, return, and run a nested for-loop?

php - Is it possible to have a function that can generate, return, and run a nested for-loop?

function generate_loop($x)
{
...
...
return $loop;
}

generate_loop(3);
generate_loop(6);


would do this:

for $i...
for $j...
for k...


for $i...
for $j...
for k...
for l...
for m...
for n...

Answer Source

I think you refer this below answer because in this problem is similar but not same this is just for your reference.

PHP - Nest a for loop a variable number of times

I hope this is helpful.

Enjoy Coding.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download