I want to retrieve my data into a two-dimensional array that I can navigate through with a foreach loop, and be able to add new fields to the array afterwords.
foreach($query_results as $qr)
$qr->brand_new_field = retrieve_other_data($qr->first_field, $qr->second_field);
m going around in circles with this but I cant quite seem to get it right. Any suggestions?
In a foreach loop, the "as' portion is actually a temporary variable built for that instance, assigned to the value from the subject array. Therefore, modifying $qr won't do anything, as it's not part of the array. Does that make sense?
foreach($query_results as $k=>$qr)
$query_results[$k]->brand_new_field = retrieve_other_data($qr->first_field, $qr->second_field);
Also this is off topic, but if you are doing queries within that loop, you are doing it terribly wrong. But that's for another thread.
This topic is now closed. New replies are no longer allowed.