fork download
  1. <?php
  2. function flipAndGroup($input) {
  3. $outArr = array();
  4. array_walk($input, function($value, $key) use (&$outArr) {
  5. if(!isset($outArr[$value]) || !is_array($outArr[$value])) {
  6. $outArr[$value] = [];
  7. }
  8. $outArr[$value][] = $key;
  9. });
  10. return $outArr;
  11. }
  12. // your code goes here<?php
  13. $array1 = array(1, "fruit" => "banana", 2, "monkey", 3);
  14. $array2 = array("a", "b", "fruit" => "apple", "city" => "paris", 4, "c");
  15. $a = $arr =[
  16. 'tax_status' =>
  17. 0 => '1',
  18. 1 => '2',
  19. )];
  20. $arr = array (
  21. 'tax_status' =>
  22. 0 => '1',
  23. 1 => '2',
  24. ),
  25. 'coverage' =>
  26. 0 => '3',
  27. 1 => '3',
  28. ),
  29. 'value' =>
  30. 0 => '54000000',
  31. 1 => '58500000',
  32. ),
  33. 'vpc' =>
  34. 0 =>
  35. 0 => '4500000',
  36. 1 => '4500000',
  37. 2 => '4500000',
  38. ),
  39. 1 =>
  40. 0 => '4500000',
  41. 1 => '4500000',
  42. 2 => '4500000',
  43. ),
  44. ),
  45. ) ;
  46. // Merging arrays together
  47. $result = array_merge($array1, $array2);
  48. $fliped = array_flip($a);
  49. print_r($fliped);
  50. // your code goes here
Success #stdin #stdout #stderr 0.02s 24372KB
stdin
Standard input is empty
stdout
Array
(
)
stderr
PHP Warning:  array_flip(): Can only flip STRING and INTEGER values! in /home/1Ei7PN/prog.php on line 55