|
array_columnReturn the values from a single column in the input array Description
array array_column(array
$array , intstringnull $column_key , intstringnull $index_key = null )
array_column returns the values from a single column of
the Parameters
Return ValuesReturns an array of values representing a single column from the input array. Changelog
Examples
Example #1 Get the column of first names from a recordset
The above example will output: Array ( [0] => John [1] => Sally [2] => Jane [3] => Peter )
Example #2 Get the column of last names from a recordset, indexed by the "id" column
The above example will output: Array ( [2135] => Doe [3245] => Smith [5342] => Jones [5623] => Doe )
Example #3 Get the column of usernames from the public "username" property of an object
The above example will output: Array ( [0] => user 1 [1] => user 2 [2] => user 3 )
Example #4 Get the column of names from the private "name" property of an object using the magic __get method.
The above example will output: Array ( [0] => Fred [1] => Jane [2] => John ) |