Skip to content
Advertisement

Two ForEach Loops In PHP With Array Of Objects

I am using php to query MySQL and am returning an array of objects.

I then iterate the array by using foreach ($sql as $res) {

In those query results in $sql I need to also iterate one of the fields called storeName

How can I create a second foreach loop to iterate over each storeName in $res

Advertisement

Answer

Use -> notation if $res is object:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement