Get a list of categories ids

Ok, I thought I was out of options after few hours spent on this little piece of code. But somehow I managed to get result, just after I hopelessly posted the question here.

$terms = wp_get_object_terms( $id_array, 'portfolio_category' );

$new_array = array();
foreach($terms as $key => $term) {
    $new_array[$key] = $term->term_id;
}

$cat_ids = implode(',', $new_array);

$categories = get_categories(
    array(
        'include'                  => $cat_ids,
        'taxonomy'                 => 'portfolio_category'
    )
);

Maybe somebody could comment on this solution?