I want to have an array following this pattern:
[1] => Array
(
[es] => 11
[pt] => 22
[br] => 333
)
[2] => Array
(
[es] => 1221
[pt] => 23442
[br] => 344433
)
Every item (including the key) comes from a query. So, I've tried including items in the following way:
array[1]= array('es'=>'11');
array[1]+= array('pt'=>'22');
This works fine if I hardcode the data manually. However, it fails when iterating through the mysql data:
foreach($elements as $value) {
$available = $value['purchased'] - $value['used'];
$credits[$value['type']]= array($value['country']=>$availableCredit);
}
I get the following error:
Fatal error: Unsupported operand types
P.S. $value['type'] only comprises "1" or "2".
$array[1]['es'] = 23, and then$array[1]['pt'] = 47etc.