Check out example codes for "Implement a groupByOwners function that: Accepts an associative array". It will help you in understanding the concepts better.

Code Example 1

function groupByOwners(array $files) : array
{
    $result = [];

    foreach($files as $file => $owner) {
        $result[$owner][] = $file;
    }

    return $result;
}

Learn ReactJs, React Native from akashmittal.com