Im wondering if array_column keeps the array elements order so when i call the function twice in same array, i can trust the resulting arrays will match. I need to work this way because in the code I have to make many operations with only specific data (one of the keys, in the example, the id), and after all, use both of them (in example id and qty) to insert in db.
Example:
QUERY: SELECT id, qty FROM items ...
CONVERTED INTO ASSOCIATIVE ARRAY:
$array = [
['id' => 1, 'qty' = 2],
['id' => 2, 'qty' = 4]
];
$itemsIds = array_column($array, 'id');
$itemsQty = array_column($array, 'qty');
Can i do?:
for($i = 0; $i < count($array); $i++) {
echo $itemsIds[$i] . $itemsQty[$i];
}
And i will always get the correct data for each item?