I have the following array:
Array
(
[0] => 1-6
[1] => 1-7
[2] => 2,9
)
I would like to group it according to their initial number.
Example result (I'm not sure of this syntax, but just to give the example):
Array
(
[0] => Array
(
[] => 1-6,
[] => 1-7
)
[1] => Array
(
[] => 2-9
)
)
How can I do this?
NOTE: Numbers can vary because they come from dynamic records. I thought about creating several arrays manually, but I can not because they can vary at any time.
Any ideas?
I tried this, but no results. I tried to blow each line using the "-" tab, but I did not find an efficient way to group them:
foreach($arrayCategorias as $key => $val){
$exploded = explode('-', $key);
$results[$exploded[0]][$exploded[1]] = $val;
}