Javatpoint Logo
Javatpoint Logo

PHP array_column() function

It is an inbuilt function in PHP. The array_column() function is used to return the values from a single column in the input array. This function is introduced in PHP 5.5.


Parameter Description Is compulsory
array Specifies the multi-dimensional array to use compulsory
Column_key This parameter may be an integer or a string key name of the column of values to return. It may also be NULL to return complete arrays (useful together with index_key to re-index the array) compulsory
index_key This parameter may be an integer key or a string key name of the column. It is used to provide the index/keys for the returned array optional

Example 1


Array(  [0] => sid    [1] => sonoo  )

Example 2


Array ( [0] => c  [1] => java  [2] => php )

Example 3


Array (   [11] => c   [12] => php  [13] => java )

Example 4


Array ( [0] => Cricket  [1] => Football   [2] => Chess )

Help Others, Please Share

facebook twitter pinterest