通过按键合并2阵列 [英] Merging 2 arrays by keys
本文介绍了通过按键合并2阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有2组,在2个数组的原因是因为2下拉从表单提交。
There are 2 arrays, the reason for 2 arrays is because of 2 drop down from form post.
array1
1 => 878
2 => 983
3 => 717
array2
1 => 10
2 => 15
3 => 12
我要环路2阵列和获得,其中键匹配,它们组合成一个阵列。
I have to loop 2 arrays and get where the keys matched and combine them into an array.
878 => 10
983 => 15
717 => 12
谢谢!
推荐答案
使用 array_combine 。试试这里
using the array_combine. try it here
$combined = array_combine(array_values($array1),array_values($array2));
这篇关于通过按键合并2阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文