在数值的基础上将数组拆分为两个

时间:2016-06-28 18:31:49

标签: php arrays

我想根据值将数组拆分为两个。

例如

Array(
    [25] => Korea Strawberry (Pkt) 250g
    [26] => *8887187338308
    [27] => PROM Mix 2@38.9G
    [28] => 19.90*2 38.90 Z
    [29] => 0.45*2
    [30] => 
    [31] => 
    [32] => Total with GST @ 6%
    [33] => Rounding
    [34] => Total
    [35] => Tender
    [36] => Master 0003 App: 807946
    [37] => Change
    [38] => GST Analysis Goods Tax Amount
    [39] => S = 6%
    [40] => Item 3
    [41] => Qty 4
    [42] => Total Saving 9.44
    [43] => 56.94
)

我希望它分为两部分。在Total with GST @ 6%之前的所有值都是所有剩余值。

我该怎么做?我尝试了array_diff()和其他方法,但没有像我想要的那样工作。

2 个答案:

答案 0 :(得分:1)

您可以使用<div class="wrapper"> <img src="http://placehold.it/350x350" width="100%" alt="wide-image"> </div> <div class="imagelist"> <img src="http://placehold.it/350x350"> <img src="http://placehold.it/350x350"> <img src="http://placehold.it/350x350"> <img src="http://placehold.it/350x350"> <img src="http://placehold.it/350x350"> <img src="http://placehold.it/350x350"> <img src="http://placehold.it/350x350"> </div>获取Total with GST @ 6%的密钥编号,然后使用2个循环拆分数组。

array_search

答案 1 :(得分:0)

您正在寻找array_slice

在关联数组或具有任意数字键的数组中使用它时要小心。

相关问题