- array_map: documentation ( source)
- print_r: documentation ( source)
<?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);