减少/过滤数组

I have an array which I want to filter out certain keys. Let's say $subcats equals this array:

Array
(
    [0] => stdClass Object
        (
            [term_id] => 4
            [term_group] => 0
            [term_taxonomy_id] => 4
            [taxonomy] => category
        )

    [1] => stdClass Object
        (
            [term_id] => 5
            [term_group] => 0
            [term_taxonomy_id] => 5
            [taxonomy] => category
        )

)

All I want is the term_ids in it's own array.

I've tried foreach and array_values, but I can't seem to wrap my head around it at the moment. Should I be using array_filter?

So the result should be $term_ids = array( 4, 5 );

$termIds = array_map(function($i) { return $i->term_id; }, $subcats);

This syntax requires PHP 5.3+.