0

I'm new to PHP and want to make an array of more than one array into a single object/array and where the number of child arrays is not necessarily known.

So this:

$events = [
  [
    "one",
    "two",
    "three",
  ],
  [
    "four",
    "five",
    "six",
  ]
];

Becomes:

$mergedEvents = [
    "one",
    "two",
    "three",
    "four",
    "five",
    "six",
];

Tried: $mergedEvents = array_merge($events[0], $events[1]); works if you have static number but I need to flatten(?) it when child array count is unknown.

Kirk Ross
  • 6,413
  • 13
  • 61
  • 104

0 Answers0