Problems related to multi-layer nested foreach ~

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.