fork(5) download
  1. <?php
  2.  
  3. $menuCategories = [
  4. 120,
  5. 120 => [1201 , 1202, 1203, 1204, 1205, 1206],
  6. 121,
  7. 121 => [1211, 1212, 1213],
  8. 122,
  9. 122 => [1221, 1222, 1223, 1224],
  10. 123,
  11. 123 => [1232],
  12. 124,
  13. 124 => [1241, 1242],
  14. 125,
  15. 125 => [1251, 1252],
  16. 126,
  17. 126 => [1261, 1262, 1263, 1264, 1265, 1266]
  18. ];
  19. $menuCategoriesFlat = [];
  20. array_walk_recursive($menuCategories, function($value) use (&$menuCategoriesFlat) {
  21. $menuCategoriesFlat[] = $value;
  22. });
  23. var_dump($menuCategoriesFlat);
  24.  
  25.  
Success #stdin #stdout 0.02s 20568KB
stdin
Standard input is empty
stdout
array(25) {
  [0]=>
  int(120)
  [1]=>
  int(1201)
  [2]=>
  int(1202)
  [3]=>
  int(1203)
  [4]=>
  int(1204)
  [5]=>
  int(1205)
  [6]=>
  int(1206)
  [7]=>
  int(1211)
  [8]=>
  int(1212)
  [9]=>
  int(1213)
  [10]=>
  int(1221)
  [11]=>
  int(1222)
  [12]=>
  int(1223)
  [13]=>
  int(1224)
  [14]=>
  int(1232)
  [15]=>
  int(1241)
  [16]=>
  int(1242)
  [17]=>
  int(1251)
  [18]=>
  int(1252)
  [19]=>
  int(1261)
  [20]=>
  int(1262)
  [21]=>
  int(1263)
  [22]=>
  int(1264)
  [23]=>
  int(1265)
  [24]=>
  int(1266)
}