Skip to content

Instantly share code, notes, and snippets.

@draobrehtom
Created January 25, 2025 22:13
Show Gist options
  • Select an option

  • Save draobrehtom/08fd9326ed4f73086eafae3b5c7abc25 to your computer and use it in GitHub Desktop.

Select an option

Save draobrehtom/08fd9326ed4f73086eafae3b5c7abc25 to your computer and use it in GitHub Desktop.
Creates unique keys by combining specified row values Maps those keys directly to their corresponding rows Provides more flexibility Significantly improves performance
protected function mapReportDataByKeys(array $data, array $keys, ?string $delimiter = '-'): array
{
return array_combine(
array_map(
fn($row) => implode($delimiter, array_map(fn($key) => $row[$key], $keys)),
$data
),
$data
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment