Merging 2 arrays by keys

匿名 (未验证) 提交于 2019-12-03 02:42:02

问题:

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 

I have to loop 2 arrays and get where the keys matched and combine them into an array.

878 => 10 983 => 15 717 => 12 

Thanks!

回答1:

using the array_combine. try it here

$combined = array_combine(array_values($array1),array_values($array2)); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!