数组合并PHP和相同的索引 [英] array merge php with same index
本文介绍了数组合并PHP和相同的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这种情况:
$qty = array(1) {[0]=> array(1) { ["qty"]=> string(5) "35254" }
$price = array(1) {[0]=> array(1) { ["price"]=> string(5) "1000" }
我怎样才能得到呢?
How can I get this?
$res = array(1) {[0]=> array(1) { ["qty"]=> string(5) "35254" ["price"]=> string(5) "1000"}
感谢您的答案
推荐答案
可能是你想要的:
$res = array();
foreach($qty as $k => $v){
$res[$k] = array_merge($qty[$k],$price[$k]);
}
结果:
array(1) {[0] => array(2) { 'qty' => string(5) "35254" 'price' => string(4) "1000" } }
这篇关于数组合并PHP和相同的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文