, foreach can only traverse the first child when traversing a three-dimensional array.

Source: Internet
Author: User
For expert guidance, foreach can only traverse the first child when traversing a three-dimensional array, which is why?


$val) {
?>


onclick= "Task ( ,' ') ' >






%; height:6px; Background: #23bd00; " >


&workcenter_id= &plan_id= ' "id=" show ">
View


$countParent = $key +1+ $count; $child = 0;
if (Is_array ($val [$key])) foreach ($val [$key] as $v) {//This only executes once
if ($val [' id ']== $v [' parent_id ']) {
$count = $count +1; $child = $child +1;
?>








%; height:6px; Background: #23bd00; " >



}
}}?>


------to solve the idea----------------------
Not particularly clear about your data structure, check if this condition is satisfied
if (Is_array ($val [$key]))
------to solve the idea----------------------
Your outer loop is
foreach ($monitorList as $key = $val)
The condition for entering the inner loop is
if (Is_array ($val [$key]))
There is no output when the condition is not met



------to solve the idea----------------------
if (Is_array ($val)) {//Determines whether the value of $val is an array, and if so, goes to the downlevel traversal
------to solve the idea----------------------
Ought to be
if (Is_array ($val)) Judge if there is a next layer
  • 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.