I have
$Array1 = [3=>'dog', 7=>'cat', 9=>'duck', 10=>'dog', 11=>'dog'];
$Array2 = ['cat'=>'sofa', 'dog'=>'kennel', 'duck'=>'pond'];
I want the output $ArrayOut where
$ArrayOut = [3=>'kennel', 7=>'sofa', 9=>'pond', 10=>'kennel', 11=>'kennel'];
I can do this easily through a foreach loop
foreach ($Array1 as $key => $value) {
$ArrayOut[$key] = $Array2[$value];
}
but I was thinking if I could avoid a loop and use a combination of inbuilt PHP array functions to create the same output.
Any clue would be helpful thanks.