I'm trying to build an array that I can output using JSON. For whatever reason, it will only add one element to the array, even if there are multiple email addresses that come back with the object. I know this because the loop executes the correct amount of times. However the new values are not added to the array. I tried array_push but it mal forms the array and jQuery wont process it correctly.
$load_model = $this->loadModel("LoadModel");
$x = $load_model->updateLoad($LoadRate, $carrID, $comment, $temp, $loadStatus, $contactID, $load_id);
if($x==true){
$arr=array();
foreach($load_model->loadEmailAddresses($load_id) as $val){
$arr['Email']= $val->Email;
$arr['ContactId']= $val->ContactId;
}
echo json_encode($arr);
}
any ideas anyone?