I have some data coming into a page with multiple rows and columns. I am specifically looking to take 1 entire column and put it into another array.
I am using codeigniter and php. The var dump on my page shows that the data in its raw array is arriving just fine. But once I start to try and create a second array on the page, the array returns 0 results.
Here is the var_dump for the original array. For your sanity, ill only post the first sequence.
array(7) { [0]=> object(stdClass)#19 (7) { ["id"]=> string(1) "1"
["serial_number"]=> string(9) "battery 1" ["battery_type"]=> string(4) "Lipo" ["cell_count"]=> string(1) "4" ["capacity"]=> string(4) "16.8" ["date_submitted"]=> string(19) "0000-00-00 00:00:00" ["user_id_submitted"]=> string(0) "" } [1]=>
Here is the array_column function
<?php
$serialnumber = array_column($batteryDb, "serial_number");
var_dump($serialnumber);
?>
and here is the result:
array(0) { }
$batteryDbhas not the right structure. It has to be an array of arrays. Would you be so nice to add the output ofvar_dump($batteryDb);to your original post - maybe just two items.