I have an object and inside that object are further objects. I want to get the value of those objects. Thanks!
foreach($query as $row){
$vehicles[$row->deviceID] = Array(
'description' => $row->description,
'deviceID' => $row->deviceID
);
}
and then I pass it to the view and stored it to a global javascript variable.
var vehicleList = <?php echo $vehicleList; ?>;
here is the output of my console.log if I type vehicleList in my console log in chrome:
vehicleList
>Object
>11292: Object
description: "Bus 1"
>11293: Object
description: "Bus 2"
>11294: Object
description: "Bus 1"
The value I want to get is the description.
Is it also possible to store another value to the object 11292? If yes, how?
Thanks!
1 Answer