[Solved] split an array into multiple part based on key pattern [duplicate]


If I understand correctly you can do it like the following, but it is an XY problem, why are you not structuring your arrays properly first?

$normalised = [];
foreach ($array as $key => $value) {
    list($k, $a) = explode('-', $key, 2);
    $normalised[$k][$a] = $value;
}

4

solved split an array into multiple part based on key pattern [duplicate]