<?php $a1 = ['a', 'b', 'c'];$a2 = ['a'=>10, 'b'=>20, 'c'=>30,'d' => 40]; print_r(array_intersect_key($a2, array_flip($a1)));
Standard input is empty
Array ( [a] => 10 [b] => 20 [c] => 30 )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!