I have a array of objects like this one:
Array
(
[0] => stdClass Object
(
[art_id] => 76
[title] => whatever
)
[1] => stdClass Object
(
[art_id] => 216
[title] => blabla
)
)
Can I somehow get a array with all art_id
's from it, without having to iterate it?
(like array(76, 216)
)
function getArtId($obj)
{
return $obj->art_id;
}
$b = array_map("getArtId", $a);
print_r($b);
This is indirectly an iteration, but you do not need to write code for the loop yourself.