合并数组上的数组(不同的键)PHP

I would like to display a set of answers to a specific question - with different answers based on a country - no problem with the foreach side of this.

However, I only have access (in this array - $answers) to an ID value for the country name. This ID will match another Key in a different array ($countries) and I'd like to output the country name instead of the ID value.

Where the [ques_jurisduction] ID matches the term_id value below, I'd like to append and output the value in [name] - essentially allowing me to replace the ID in the output with the correct country name.

Print_r for each gives:

$answers

Array ( [ques_jurisdiction] => 5 [ques_answer] => )

$countries

Array ( [1] => WP_Term Object ( [term_id] => 119 [name] => Austria [slug] => austria [term_group] => 0 [term_taxonomy_id] => 119 [taxonomy] => wgd_jurisdiction [description] => [parent] => 0 [count] => 96 [filter] => raw ) [value] => WP_Term Object ( [term_id] => 119 [name] => Austria [slug] => austria [term_group] => 0 [term_taxonomy_id] => 119 [taxonomy] => wgd_jurisdiction [description] => [parent] => 0 [count] => 96 [filter] => raw ) [0] => 0 [key] => 0 )

Any guidance most appreciated. Think I might be getting a bit confused with Taxonomies and sub_fields!

Thanks

As per my understanding, you want to output name of country and you have its term_id as in ques_jurisdiction index of $answers array. I also noticed that your index 1 and value contains same values in $countries array. If I am right till now then you can achieve what you want like this:

foreach($countries['value'] as $obj){
    if($obj->term_id === $answers['ques_jurisdiction']){
       echo $obj->name; //It will output country name, you can as well take it in some variable to use it later on
    }
}

I have used 'value' index, you can as well use index 1 as they both contains same data.

I hope it helps