Easy Tutorial
❮ Php Spaceship Operator Func Filesystem Is Readable ❯

PHP array_column() Function

Complete PHP Array Reference Manual

Example

Extract the last_name column from the record set:

Output:


Definition and Usage

array_column() returns the values from a single column of the input array.


Syntax

Parameter Description
array Required. Specifies the multi-dimensional array (record set) to use.
column_key Required. The column whose values are to be returned. It can be an integer index of the column in an indexed array or a string key of the column in an associative array. This parameter can also be NULL, in which case the entire array will be returned (useful when combined with the index_key parameter to reset the array keys).
index_key Optional. The column to use as the index/key for the returned array.

Technical Details

Return Value: Returns an array, the values of which are from a single column of the input array.
PHP Version: 5.5+
--- ---

More Examples

Example 1

Extract the last_name column from the record set, using the corresponding "id" column as the key:

Output:


❮ Php Spaceship Operator Func Filesystem Is Readable ❯