“Implement a groupByOwners function that: Accepts an associative array” Code Answer
<?php
class FileOwners
{
public static function groupByOwners($files)
{
$newArray = array();
foreach($files as $key=>$f){
// this will return all the array value based on key
$newArray[$f] = array_keys($files, $f);
//$newArray[$f][] = $key;
}
return $newArray;
}
}
$files = array
(
"Input.txt" => "Randy",
"Code.py" => "Stan",
"Output.txt" => "Randy"
);
var_dump(FileOwners::groupByOwners($files));