|
array_columnReturn the values from a single column in the input array Beschreibung
array array_column
( array
$input
, mixed $column_key
[, mixed $index_key = null
] )
array_column returns the values from a single column of
the Parameter-Liste
RückgabewerteReturns an array of values representing a single column from the input array. Changelog
Beispiele
Beispiel #1 Get the column of first names from a recordset
<?phpDas oben gezeigte Beispiel erzeugt folgende Ausgabe:
Array
(
[0] => John
[1] => Sally
[2] => Jane
[3] => Peter
)
Beispiel #2 Get the column of last names from a recordset, indexed by the "id" column
<?phpDas oben gezeigte Beispiel erzeugt folgende Ausgabe:
Array
(
[2135] => Doe
[3245] => Smith
[5342] => Jones
[5623] => Doe
)
Beispiel #3 Get the column of usernames from the public "username" property of an object
<?phpDas oben gezeigte Beispiel erzeugt folgende Ausgabe:
Array
(
[0] => user 1
[1] => user 2
[2] => user 3
)
Beispiel #4 Get the column of names from the private "name" property of an object using the magic __get method.
<?phpDas oben gezeigte Beispiel erzeugt folgende Ausgabe:
Array
(
[0] => Fred
[1] => Jane
[2] => John
)
|