[eluser]kevinprince[/eluser]
I have been trying this afternoon to add a value to an array during a foreach loop, however it just doesnt seem to work.
I investigated on php.net and foreach does not touch the original array just loads a copy into memory. There is then the usual mess of php.net explanations which I cant get my head around on how to solve it.
My code is below, so if you have any ideas on how to solve it let me know its mighty annoying.
Code:
///Get List of Events
$eventlist = $this->EventModel->get_parent_events();
///Loop through events retrieved
foreach($eventlist as $item):
$eventid = $item['eventid'];
///Get the number of attendees from MYSQL
$event_attendance = $this->EventModel->count_parent_attendence($eventid);
///Append the open array with the count
$item['count'] = $event_attendance['count'];
endforeach;
print_r($eventlist);