-1

Hi I would like to split an array based on its value. Say for example my array is like this

 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
    )

) I would like to split the array in bill_id basis. Means array with same bill id must come under one section. Please help me to achieve this.

Ajzz
  • 340
  • 1
  • 7
  • 22

1 Answers1

0

That's call group by, check this link

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

Hope this helps you.

Ashish Kadam
  • 1,439
  • 2
  • 13
  • 18