I have the following two arrays:
Array One
Array ( [0] => WP_Term Object ( [term_id] => 36 [name] => Fractions [slug] => fractions-cat [term_group] => 0 [term_taxonomy_id] => 36 [taxonomy] => emp_unit_name [description] => [parent] => 0 [count] => 11 [filter] => raw [term_order] => 0 )
[1] => WP_Term Object ( [term_id] => 38 [name] => Geometry [slug] => geometry [term_group] => 0 [term_taxonomy_id] => 38 [taxonomy] => emp_unit_name [description] => [parent] => 0 [count] => 2 [filter] => raw [term_order] => 0 )
)
Array Two
Array ( [0] => WP_Term Object ( [term_id] => 36 [name] => Fractions [slug] => fractions-cat [term_group] => 0 [term_taxonomy_id] => 36 [taxonomy] => emp_unit_name [description] => [parent] => 0 [count] => 11 [filter] => raw [term_order] => 0 ) )
I'm trying to compare the two arrays to find if there are any matches for the [term_id] values as such:
$match = array_intersect($array_one_ids, $array_two_ids);
if( count($match) > 0) { echo 'we have a match!'; }
My question is, how can I create arrays (defined by $array_one_ids
and $array_two_ids
) of just the term_id
values in each of the above arrays such that $array_one_ids
would = array(36, 38)
and $array_two_ids
would = array(36)
?