Iterating over a complex Associative Array in PHP

后端 未结 7 1931
广开言路
广开言路 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:54

    I'm really not sure what you mean here - surely a pair of foreach loops does what you need?

    foreach($array as $id => $assoc)
    {
        foreach($assoc as $part => $data)
        {
            // code
        }
    }
    

    Or do you need something recursive? I'd be able to help more with example data and a context in how you want the data returned.

提交回复
热议问题