PHP » GoLang |
login |
register |
about
|
array_column(PHP 5 >= 5.5.0, PHP 7) array_column — Return the values from a single column in the input array Description
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
<?phpThe 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
<?phpThe 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
<?phpThe 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.
<?phpThe above example will output:
Array
(
[0] => Fred
[1] => Jane
[2] => John
)
|
more
Most requested
more
Last requests
|