3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = new stdClass(); $a->id = 17; $a->res_id = 10; $a->cat_id = 3; $b = new stdClass(); $b->id = 18; $b->res_id = 10; $b->cat_id = 4; $c = new stdClass(); $c->id = 52; $c->res_id = 19; $c->cat_id = 1; $d = new stdClass(); $d->id = 53; $d->res_id = 19; $d->cat_id = 3; $e = new stdClass(); $e->id = 54; $e->res_id = 19; $e->cat_id = 4; $array = Array ( $a, $b, $c, $d, $e ); $result = array_map(function($x){ return $x->cat_id; }, $array); print_r($result);
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0beta1
Array ( [0] => 3 [1] => 4 [2] => 1 [3] => 3 [4] => 4 )