Support

Account

Home Forums Add-ons Repeater Field Order repeater rows by date Reply To: Order repeater rows by date

  • You can construct a custom array after the sorted array.

    
    ... 
    array_multisort( $order, SORT_DESC, $repeater );
    
    $actual_loop = [];
    
    foreach ($repeater as $row) {
        // if this is a new date, we create a new array item
        if (! isset($actual_loop[$row['date']])) {
            $actual_loop[$row['date']] = [
                'date' => $row['date'],
                'rows' => []
            ];
        }
    
        $actual_loop[$row['date']]['rows'][] = $row;
    }
    
    foreach ($actual_loop as $loop) {
        echo '<h3>' . $loop['date'] . '<h3>';
        ecoh '<ul>';
    
        foreach ($loop['rows'] as $row) {
            echo "<li>{$row['actividad']}. {$row['aula']}. {$row['hora_de_inicio']} - {$row['hora_de_fin']}</li>";
        }
    
        echo '</ul>';
    }
    

    Cheers