Foreach multi-layer nesting problem, solution ~! & Lt ;? Php $ a1 = explode (',', '20, 21'); $ b1 = explode (',', '20, 21'); $ c1 = explode (', ', '20, 21'); $ d1 = explode (', ', '20, 21'); $ e1 = explode (', ', '20, foreach multi-layer nesting problem, solution ~!
$a1=explode(',','20,21');
$b1=explode(',','20,21');
$c1=explode(',','20,21');
$d1=explode(',','20,21');
$e1=explode(',','20,21');
foreach($a1 as $a ){
foreach($b1 as $b){
foreach($c1 as $c){
foreach($d1 as $d){
foreach($e1 as $e){
}
}
}
}
}
?>
Page error:
Rendering failed. specific error: loop nest level reach limited!
Excuse me,
This error is caused by PHP restrictions,
Or what?
If I have to nest so many layers,
Is there any good solution?
Thank you. give me some suggestions ~!
------ Solution --------------------
The purpose of your nesting is that $ a1 is a multi-dimensional array, $ b1 is a sub-array of $ a1, and $ c1 is a sub-array of $ b1.
The example provided by the landlord is not suitable. your example is equivalent to $ a1, $ b1, and $ c1 are mutually independent one-dimensional arrays. therefore
Traversal like you, of course, returns the result.
According to your example, only
foreach($a1 as $a ){
echo $a;
}
foreach($b1 as $b ){
echo $b;
}
$ A1 and $ b1 are independent of each other and there is no relationship between them.