How exactly can I apply array_column always getting the first column of an array instead of getting the column by name? This is:
array_column($array,[0])
instead of
array_column($array,"key");
The array_column() function returns the values from a single column in the input array.
array_keys() returns the keys, numeric and string, from the array . If a search_value is specified, then only the keys for that value are returned. Otherwise, all the keys from the array are returned.
An associative array is an array with string keys rather than numeric keys. Associative arrays are dynamic objects that the user redefines as needed. When you assign values to keys in a variable of type Array, the array is transformed into an object, and it loses the attributes and methods of Array.
Try
array_column($array, array_shift(array_keys($array)));
from Return first key of associative array in PHP
Hope can help! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With