如何匹配数组键与数组值。使用array_intersect()函数可以匹配键数组。但如何将第一个数组中的键与第二个数组中的值匹配呢?
例如,给定以下数组:
如果使用 array_intersect(),它是用来匹配键的。我想要搜索键数组并获取值数组。输出将会像这样显示:
例如,给定以下数组:
$value_array=array(
'1'=>'text one',
'2'=>'text two',
'3'=>'text three',
'4'=>'text four',
'5'=>'text five',
'6'=>'text six',
'7'=>'text seven',
'8'=>'text eight',
'9'=>'text nine',
'10'=>'text ten'
);
$key_array=array(
'1'=>'1',
'2'=>'2',
'3'=>'4',
'4'=>'5',
'5'=>'7'
);
如果使用 array_intersect(),它是用来匹配键的。我想要搜索键数组并获取值数组。输出将会像这样显示:
Array (
[1] => text one
[2] => text two
[3] => text four
[4] => text five
[5] => text seven
)