Home > Backend Development > PHP Tutorial > 怎么从一个数组里拆出一部分作为一个新数组

怎么从一个数组里拆出一部分作为一个新数组

WBOY
Release: 2016-06-13 10:24:30
Original
1083 people have browsed it

如何从一个数组里拆出一部分作为一个新数组。
Array
(
  [totalcount] => 2
  [errorcount] => 0
  [orderlist] => Array
  (
  [order] => Array
  (
  [0] => Array
(
[orderamount] => 130.0
[ordercode] => 11111009FTHT
[ordercreatetime] => 2011-11-11 20:44:32
[orderdeliveryfee] => 0.0
[orderid] => 21919876
[orderneedinvoice] => 0
[orderstatus] => ORDER_OUT_OF_WH
[productamount] => 130.0
)

[1] => Array
(
[orderamount] => 200.0
[ordercode] => 3311009FTHT
[ordercreatetime] => 2011-05-11 20:44:32
[orderdeliveryfee] => 0.0
[orderid] => 21919876
[orderneedinvoice] => 0
[orderstatus] => ORDER_OUT_OF_dfd
[productamount] => 130.0
)

  )

  )

  [encoding] => UTF-8
)




这个数组 我需要[order] 里面的部分 提出来作为一个新数组, 怎么处理呢。

------解决方案--------------------
$new_arr = $all_arr['order'];
------解决方案--------------------
假设$arr为你的原数组.
$NewArr=$arr['order'];
------解决方案--------------------
楼上两位没看清楚数组结构吧:

PHP code
//对需要的数组进行修改$newArr=$arr['orderlist']['order'];//如果需要将修改的结果合并回原数组:$arr['orderlist']['order']=$newArr;<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template