Iterating over a complex Associative Array in PHP

后端 未结 7 1912
广开言路
广开言路 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 17:45

    Nest two foreach loops:

    foreach ($array as $i => $values) {
        print "$i {\n";
        foreach ($values as $key => $value) {
            print "    $key => $value\n";
        }
        print "}\n";
    }
    

提交回复
热议问题