fork download
  1. <?php
  2.  
  3. $array = [
  4. ['ABC' => 1],
  5. ['ADC' => 2],
  6. ['AXC' => 15],
  7. ['XAC' => 15]
  8. ];
  9.  
  10. // primeiro flatten
  11.  
  12. array_walk_recursive($array, function ($value, $key) use (&$flatted) {
  13. $flatted[$key] = $value;
  14. });
  15.  
  16. var_dump($flatted);
  17.  
  18. // segundo flatten
  19. var_dump(array_merge(...$array));
  20.  
  21.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
array(4) {
  ["ABC"]=>
  int(1)
  ["ADC"]=>
  int(2)
  ["AXC"]=>
  int(15)
  ["XAC"]=>
  int(15)
}
array(4) {
  ["ABC"]=>
  int(1)
  ["ADC"]=>
  int(2)
  ["AXC"]=>
  int(15)
  ["XAC"]=>
  int(15)
}