Iterating over a complex Associative Array in PHP

后端 未结 7 1920
广开言路
广开言路 2020-11-27 17:00

Is there an easy way to iterate over an associative array of this structure in PHP:

The array $searches has a numbered index, with between 4 and 5 assoc

7条回答
  •  隐瞒了意图╮
    2020-11-27 18:00

    You should be able to use a nested foreach statment

    from the php manual

    /* foreach example 4: multi-dimensional arrays */
    $a = array();
    $a[0][0] = "a";
    $a[0][1] = "b";
    $a[1][0] = "y";
    $a[1][1] = "z";
    
    foreach ($a as $v1) {
        foreach ($v1 as $v2) {
            echo "$v2\n";
        }
    }
    

提交回复
热议问题