Getting an array from one property of an associative array best practice I have an array of objects eg.

[
   array(
    'id' => 1,
   'name' => "simon"
),
...
]

and I need to get an array of IDs eg.
[1,2,3,4,5];

Currently I'm doing this:

    $entities = $this-&gt;works_order_model-&gt;get_assigned_entities($id);

    $employee_ids = array();

    foreach ($entities as $entity) {
        array_push($employee_ids, $entity-&gt;id);
    }       


Is there a best practice way of doing this?
I think array_map is what you are looking for:

php &gt; $aa = array (array ("id" =&gt; 1, "name" =&gt; 'what'), array('id' =&gt; 2));
php &gt; function id($i) { return $i['id'];};
php &gt; print_r(array_map ('id', $aa));
Array
(
    [0] =&gt; 1
    [1] =&gt; 2
)