<?php

/**
 * Smarty {regroup} modifier.
 */
function smarty_modifier_regroup(array $data, string $attribute): array
{
    $groups = [];

    foreach ($data as $index => $row) {
        $groups[$row[$attribute]][$index] = $row;
    }

    return $groups;
}
