I have an array like this :
$total= [20140124] => Array
(
[abc] => 0.19287878787879
[total] => 38
[revenue] => 1232
[clicks] => 1110
[score]=>100
)
[20140123] => Array
(
[abc] => 0.32898148148148
[total] => 28
[revenue] => 1142
[clicks] => 1022
[score]=>200
)
Now I am preparing another array and checking some conditions like the following:
foreach($total as $t){
$new_array[] = array(
"total"=>$t->abc;
"another_value"=>$t->revenue/$t->clicks;
);
if(some_condition){
$new_array[] = array("total_score"=>$t->clicks+$t->score);
}
}
What I need is an array like
$new_array =
[0] => Array
(
[total] => total_value
[another_value] => anopther_value
[total_score] => total_score_value
)
[1] => Array
(
[total] => total_value
[another_value] => anopther_value
[total_score] => total_score_value
)
)
But I am not getting the total_score inserted to the 0th index. Instead the whole array is replaced with the values in the if condition. How can I get the total_score also with the other indexes ?