基于php中数组中的值拆分数组

时间:2018-01-29 06:56:50

标签: php arrays

您好我想基于其值拆分数组。比如我的数组就像这样

 Array
(
 [0] => Array
    (
        [id] => 1
        [amount] => 800
        [detail] => bus fare
        [student_id] => 16
        [class_id] => 1
        [bill_id] => 5a6c176b0b27a
        [total] => 1800
    )

[1] => Array
    (
        [id] => 2
        [amount] => 1000
        [detail] => tast
        [student_id] => 16
        [class_id] => 1
        [bill_id] => 5a6c176b0b27a
        [total] => 1800
    )

[2] => Array
    (
        [id] => 3
        [amount] => 5000
        [detail] => tution
        [student_id] => 16
        [class_id] => 1
        [bill_id] => 5a6d3a1d67feb
        [total] => 5150
    )

[3] => Array
    (
        [id] => 4
        [amount] => 150
        [detail] => busfare
        [student_id] => 16
        [class_id] => 1
        [bill_id] => 5a6d3a1d67feb
        [total] => 5150
    )

) 我想以bill_id为基础拆分数组。具有相同账单ID的均值数组必须位于一个部分下。请帮我实现这个目标。

1 个答案:

答案 0 :(得分:0)

该呼叫组,请查看此link

$bill_id = Arrays::groupBy($actual_array, Functions::extractField('bill_id'));

希望这会对你有所帮助。