I have an array of 4 elements $device_report = [];
with these data in it
array:4 [▼
0 => array:2 [▼
"up_bytes" => 2818
"down_bytes" => 948
]
1 => array:2 [▼
"up_bytes" => 472
"down_bytes" => 439
]
2 => array:2 [▼
"up_bytes" => 3364
"down_bytes" => 1317
]
3 => array:2 [▼
"up_bytes" => 3102
"down_bytes" => 1682
]
]
Right now, I have this
$device_report = [];
foreach ($devices as $device){
$device_mac = $device->device_mac; //080027E2FC7D
$data = VSE::device($device_mac);
array_push($device_report,$data);
}
I've tried
$device_report = [];
foreach ($devices as $device){
$device_mac = $device->device_mac; //080027E2FC7D
$data = VSE::device($device_mac);
array_push($device_report[$device_mac],$data);
}
It give me error :
array_push() expects parameter 1 to be array, null given
I just want to my key to be a specific device Mac Address rather than 0,1,2,3.
Any hints will be much appreciated !