<?php
// 定义数组 1
$arr1 = array(
'BL001' => array(
'0' => 'A14257',
举慧 '1' => 'B17548'
),
'CDF002' => array(
'0' 搭顷=> 'A14257',
'1' => 'C48751'
),
'FGE453' => array(
'0' => 'DF5533',
'1' => 'GR6445',
'2' => 'GH5544'
),
'GEN001' => array(
'0' => 'NT7532',
'1' => 'DE9342',
'2' => 'C48751'
)
);
// 定义数组 2
$arr2 = array(
'A14257',
'E453T4',
'Y64344',
'FG4809',
'C48751',
'H4443R'
);
// 定义结果数组 $result
$result = array();
foreach ( $arr1 as $k => $v ) // 遍历数组 1
foreach ( $v as $s ) // 遍历数组 1 第 2 维
if ( in_array( $s, $arr2 ) ) { // 包含数据 2 的任意值
if ( ! isset( $result[$k] ) || ! is_array( $result[$k] ) )
知答陆 $result[$k] = array();
$result[$k][] = $s; // 添加到结果数组
}
// 输出测试结果
print_r( $result );
/*
Array
(
[BL001] => Array
(
[0] => A14257
)
[CDF002] => Array
(
[0] => A14257
[1] => C48751
)
[GEN001] => Array
(
[0] => C48751
)
)
*/