array_column
Returns the values from a single column in a multi-dimensional array or array of objects.
Parameters
main.php
Return Values
array
Returns an array of values from the specified column
On success:Array containing values from the specified column
On failure:Empty array if column doesn't exist or input is invalid
Notes
- Works with both arrays and objects (public properties only)
- Use index_key parameter to reindex the resulting array
- Objects need __get() and __isset() methods for private properties
- Essential for extracting data from database result sets
Changelog
- 7.0.0: Added ability to use column_key parameter with array of objects
- 5.5.0: Function was introduced
Related Functions
substr
StringReturns a portion of a string specified by start and length parameters.
substringextractslice
mysqli_query
DatabasePerforms a query against a MySQL database and returns a result set or boolean value.
databasemysqlquery
array_keys
ArrayReturns all keys or a subset of keys from an array, optionally filtered by value.
keysextractstructure
array_slice
ArrayExtracts a slice of an array based on offset and length parameters without modifying the original array.
sliceextractpagination