Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取两个数组的键相交?_Php_Arrays_Array Intersect - Fatal编程技术网

Php 如何获取两个数组的键相交?

Php 如何获取两个数组的键相交?,php,arrays,array-intersect,Php,Arrays,Array Intersect,我有两个数组,如图所示 //array 1 Array ( [0] => 223 [1] => 216 ) /array 2 Array ( [221] => Bakers [220] => Construction [223] => Information Technology [216] => Jewellery [217] => Photography [222] => Ret

我有两个数组,如图所示

//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
只需获取关键点的值,但由于在第一个数组中有关键点作为值,因此必须将其翻转,例如


不错。非常干净,有污点。
print_r(array_intersect_key($array2, array_flip($array1)));
$result = array();
foreach( $array1 as $index ) {
  $result[] = $array2[ $index ];
}
echo implode( ', ', $result );