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:
foreach ($sql as $res) {
foreach ($res->storeName as $store) {
print_r($store); // or whatever else
}
}