I have an array called $zip_in_distance
Array ([0] => Array([zip] => 12345, [distance] => 12345)).
If I am going to print the $value[zip]
, it is correct. But I get an empty array back. When I don't use a foreach-loop and I manually do the query, it is working. What am I doing wrong?
$shop = array();
foreach ($zip_in_distance as $key => $value) {
$q = Doctrine_Query::create()
->from('market m')
->where('m.zip = ? ', $value['zip'])
->execute();
$shop[] = $q;
}
return $shop;
My template:
foreach ($shops as $key => $list) {
echo $key . $list['id'] . '<br>';
}
I do have more than on market per zipcode. Thanks in advance!
Craphunter
Why use a foreach at all? Try something like this: