I have an array with keys that describe location in a multidimensional array like:
array(
'3728:baskets:4839:1' => 'apple',
'3728:baskets:4839:2' => 'orange',
'3728:baskets:4920:1' => 'cherry',
'3728:baskets:4920:2' => 'apple',
'9583:baskets:4729:1' => 'pear',
'9583:baskets:4729:2' => 'orange',
'9583:baskets:6827:1' => 'banana',
'9583:baskets:6827:2' => 'pineapple',
);
I would like to pass this array to a function that generates a multidimensional array based on the the pieces in the keys delimited by the ":". The resulting array should look like:
array(
3728 => array(
'baskets' => array(
4839 => array(
1 => 'apple',
2 => 'orange',
),
4920 => array(
1 => 'cherry',
2 => 'apple',
),
),
),
9583 => array(
'baskets' => array(
4729 => array(
1 => 'pear',
2 => 'orange',
),
6827 => array(
1 => 'banana',
2 => 'pineapple',
),
),
),
);
explode()the key on':', put the value in the right spot.