a::extract($array, $key)

Extracts a single column from an array

  • $array (array)
    The source array
  • $key (string)
    The key name of the column to extract
  • return (array)
    The result array with all values from that column.

Example

<?php
$array[0] = array(
   'id' => 1,
   'username' => 'bastian',
 );

 $array[1] = array(
   'id' => 2,
   'username' => 'peter',
 );

 $array[3] = array(
   'id' => 3,
   'username' => 'john',
 );


 $extract = a::extract($array, 'username');

 var_dump($extract);

Result:

array (size=3)
  0 => string 'bastian' (length=7)
  1 => string 'peter' (length=5)
  2 => string 'john' (length=4)