array merge php with same index

后端 未结 3 1004
长情又很酷
长情又很酷 2021-01-25 14:44

I have this situation:

$qty = array(1) {[0]=> array(1) { [\"qty\"]=> string(5) \"35254\" }
$price = array(1) {[0]=> array(1) { [\"price\"]=> string(5         


        
相关标签:
3条回答
  • 2021-01-25 15:08

    May be it's that you want:

    $res = array();
    foreach($qty as $k => $v){
        $res[$k] = array_merge($qty[$k],$price[$k]);
    }
    

    The result :

    array(1) {[0] => array(2) { 'qty' => string(5) "35254" 'price' => string(4) "1000" } }
    
    0 讨论(0)
  • 2021-01-25 15:08
    $qty = array("qty"=>"35254" );
    $price = array ( "price"=> "1000" );
    
    $combine = array_merge($qty,$price);
    var_dump($combine);
    
    0 讨论(0)
  • 2021-01-25 15:10

    try with

    $res = array_merge_recursive($qty, $price);
    print_r($res);
    
    0 讨论(0)
提交回复
热议问题