1. Go to this page and download the library: Download andrew-gos/helpers library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andrew-gos / helpers example snippets
use AndrewGos\Helpers\HArray;
$data = [
['city' => 'New York', 'role' => 'admin', 'name' => 'Alice'],
['city' => 'New York', 'role' => 'user', 'name' => 'Bob'],
['city' => 'London', 'role' => 'admin', 'name' => 'Charlie'],
];
// Group by city, then by role, and index elements by name
$result = HArray::groupExtended(
array: $data,
key: ['city', 'role'],
index: 'name'
);
/* Output:
[
'New York' => [
'admin' => ['Alice' => [...]],
'user' => ['Bob' => [...]],
],
'London' => [
'admin' => ['Charlie' => [...]],
]
]
*/