rep__group_listing_events()

This function, groups listing events based on a specified key and returns them as an array of grouped events.

Namespace

REP_Malcolm

Parameters

$events

array

Listing events

$key

array

Event key to group the events by

Return

array

Listing events grouped

Source

File: \includes\rep-helper-functions.php

function rep__group_listing_events( $events, $key = 'event_type' ){

    $event_group = [];

    if( ! empty($events) && is_array( $events ) ){
        
        foreach($events as $event){
            $event_group[ lp__array_key_value( 'event_type', $event ) ][] = $event;
        }
    }
   
    return $event_group;           
}