I have an associative array, with some of the values in "CAT" having multiple words, separated by a comma.
I would like to split those into separate array entries (each comma separated word to create another array entry) as shown below.
I know that I can use explode() to separate those values with commas, but not sure on how to create a new array entry from it?
$categories = explode(',', $details[0]['CAT']);
Current array structure:
Array
(
[0] => Array
(
[ID] => 50829
[CAT] => "furniture,home,garden"
)
[1] => Array
(
[ID] => 50832
[CAT] => "kids"
)
[2] => Array
(
[ID] => 50854
[CAT] => "toys"
)
)
Desired result:
Array
(
[0] => Array
(
[ID] => 50829
[CAT] => "furniture"
)
[1] => Array
(
[ID] => 50829
[CAT] => "home"
)
[2] => Array
(
[ID] => 50829
[CAT] => "garden"
)
[3] => Array
(
[ID] => 50832
[CAT] => "kids"
)
[4] => Array
(
[ID] => 50854
[CAT] => "toys"
)
)
Really appreciate your help!