CTP – check for value inside objects

There’s no need for two loops. Just iterate over the terms and use in_array():

foreach ( $terms as $term ) {
    if ( in_array( $term->slug, $months ) {
        echo 'yes';
    else 
        echo 'no';
    }
}