如何获得两个数组的关键交集?

How can I get the key intersect of two arrays?

我有两个数组,如下所示

//array 1
Array
(
    [0] => 223
    [1] => 216
)

/array 2
Array
(
    [221] => Bakers
    [220] => Construction
    [223] => Information Technology
    [216] => Jewellery
    [217] => Photography
    [222] => Retailers
)

我想要第一个数组的键(值)与第二个数组(键)匹配的文本。

预期结果:

Information Technology, Jewellery

只需获取array_intersect_key() of the keys, but since you have the keys as values in the first array you have to flip it with array_flip(),例如

print_r(array_intersect_key($array2, array_flip($array1)));
$result = array();
foreach( $array1 as $index ) {
  $result[] = $array2[ $index ];
}
echo implode( ', ', $result );