Advertisement
Guest User

mee

a guest
Feb 29th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. <?php
  2. //answer for https://www.testdome.com/questions/php/file-owners/11840?visibility=17&skillId=5
  3. class FileOwners
  4. {
  5. public static function groupByOwners($files)
  6. {
  7. $result=array();
  8. foreach($files as $key=>$value)
  9. {
  10. $result[$value][]=$key;
  11. }
  12. return $result;
  13. }
  14. }
  15.  
  16. $files = array
  17. (
  18. "Input.txt" => "Randy",
  19. "Code.py" => "Stan",
  20. "Output.txt" => "Randy"
  21. );
  22. var_dump(FileOwners::groupByOwners($files));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement