function array_flatten_with_dots(iterable
$array, string
$id = ''
): array
{ $flattened =
[];
foreach ($array as $key =>
$value) { $newKey =
$id .
$key;
if (is_array($value) &&
$value !==
[]) { $flattened =
array_merge($flattened,
array_flatten_with_dots($value,
$newKey . '.'
));
} else { $flattened[$newKey] =
$value;
} } return $flattened;
}}if (!
function_exists('array_group_by'
)) { /**
* Groups all rows by their index values. Result's depth equals number of indexes
*
* @param array $array Data array (i.e. from query result)
* @param array $indexes Indexes to group by. Dot syntax used. Returns $array if empty
* @param bool $includeEmpty If true, null and '' are also added as valid keys to group
*
* @return array Result array where rows are grouped together by indexes values.
*/