0

I have an Array containing arrays with 8 values, I want to group date element having same teacher_name, school_name and month_year.

Below is my array:

Array
(
    [0] => Array
        (
            [teacher_name] => CF
            [school_name] => School 1
            [month_year] => Jun 16
            [starttime] => 04:04 PM
            [endtime] => 05:04 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => 09
        )
    [1] => Array
        (
            [teacher_name] => CF
            [school_name] => School 1
            [month_year] => Jun 16
            [starttime] => 04:04 PM
            [endtime] => 05:04 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => 12
        )
    [2] => Array
        (
            [teacher_name] => CF
            [school_name] => School 1
            [month_year] => Oct 16
            [starttime] => 04:08 PM
            [endtime] => 05:08 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => 01
        )
    [3] => Array
        (
            [teacher_name] => CF
            [school_name] => School 1
            [month_year] => Oct 16
            [starttime] => 04:08 PM
            [endtime] => 05:08 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => 02
        )    
    [4] => Array
        (
            [teacher_name] => CF
            [school_name] => School 2
            [month_year] => Oct 16
            [starttime] => 04:08 PM
            [endtime] => 05:08 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => 11
        )
    [5] => Array
        (
            [teacher_name] => CF
            [school_name] => School 2
            [month_year] => Oct 16
            [starttime] => 04:08 PM
            [endtime] => 05:08 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => 22
        )
)           

I want like below:

Array
(
    [0] => Array
        (
            [teacher_name] => CF
            [school_name] => School 1
            [month_year] => Jun 16
            [starttime] => 04:04 PM
            [endtime] => 05:04 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => Array([0]=>09 [1]=>12) 
        )
    [1] => Array
        (
            [teacher_name] => CF
            [school_name] => School 1
            [month_year] => Oct 16
            [starttime] => 04:04 PM
            [endtime] => 05:04 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => Array([0]=>01 [02]=>02)
        )
    [3] => Array
        (
            [teacher_name] => CF
            [school_name] => School 2
            [month_year] => Oct 16
            [starttime] => 04:04 PM
            [endtime] => 05:04 PM
            [total_minutes] => 60
            [teacher_rate] => 20
            [date] => Array([0]=>11 [1]=>22)
        )

)

Edited by Abhi_6

2
Contributors
1
Reply
27
Views
1 Year
Discussion Span
Last Post by diafol
0

I.m assuming you.re getting this from a DB. You can use group by and inner join.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.