将只从指定的元素哪个键关联数组获取 [英] Get from associative array only that elements which keys are specified
本文介绍了将只从指定的元素哪个键关联数组获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这晚,我知道这是一个很简单的问题,但现在我没有一个想法,截止日期为近..
It's late and I know it is a very simple question but right now I do not have an idea and deadline is near..
我有两个数组:
$array1 = array(
'a' => 'asdasd',
'b' => 'gtrgrtg',
'c' => 'fwefwefw',
'd' => 'trhrtgr',
);
$array2 = array(
'b', 'c'
);
什么是函数的名称通过按键从第二阵列来获得assoc命令阵列的一部分?
What was the name of function to get a part of assoc array by keys from the second array ?
$result = array(
'b' => 'gtrgrtg',
'c' => 'fwefwefw',
);
谢谢!
推荐答案
试试这个:
array_intersect_key($array1, array_flip($array2)).
这篇关于将只从指定的元素哪个键关联数组获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文