PHP foreach with Nested Array?

后端 未结 4 1059
广开言路
广开言路 2020-11-27 02:53

I have a nested array in which I want to display a subset of results. For example, on the array below I want to loop through all the values in nested array[1].

Ar         


        
4条回答
  •  面向向阳花
    2020-11-27 03:10

    foreach ($tmpArray as $innerArray) {
        //  Check type
        if (is_array($innerArray)){
            //  Scan through inner loop
            foreach ($innerArray as $value) {
                echo $value;
            }
        }else{
            // one, two, three
            echo $innerArray;
        }
    }
    

提交回复
热议问题