dpwgzi7987
2018-06-07 03:27
浏览 186
已采纳

PHP按数值将数组拆分为2个数组

I'm having a hard time figuring out how to implement this so here it is. I have an array

$arr = array("purchase_order_details_id"=>array(
               0=>"POD1",
               1=>"POD1",
               2=>"POD2",
           ),
            "quantity_received"=>array(
               0=>5,
               1=>10,
               2=>20
            )
         );

I want to split the arrays into two. Into something like this.

$pod_2 = array("purchase_order_details_id"=>array(
       0=>"POD1",
       1=>"POD1"
       ),
       "quantity_received"=>array(
       0=>5,
       1=>10
       ));

$pod_1 = array("purchase_order_details_id"=>array(
       2=>"POD2"
       ),
       "quantity_received"=>array(
       2=>20
       ));

Anyone has an idea on how to do this ? Any thoughts is appreciated. Thanks

3条回答 默认 最新

相关推荐 更多相似问题