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)
        )

)
Member Avatar for diafol

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.