Class ArrayUtils

new ArrayUtils()

Methods

Permalinkpluck


pluck($data, $columnKey, $replaceEmptyWithNull)

This is a static method and can be used to extract a column from the result of a SQL query fetched as an associative array

Params
NameTypeDescription
$data Array The data
$columnKey String The key of the column to pluck
$replaceEmptyWithNull Boolean If there is no item found on that key, replace with a null (default true)
Example
$names = array(
   array('name' => 'moe', 'age' => 40),
   array('name' => 'larry', 'age' => 50),
   array('name' => 'curly', 'age' => 60)
);
ArrayUtils::pluck($names, 'name');

==> ["moe", "larry", "curly"]

Inherited Methods