I’m trying to move array items into a sub-array based on a value, so for example:
Array
(
[0] => Array
(
[Desc] => 'Sub category'
[SubID] => null
)
[1] => Array
(
[Desc] => 'Listed item 1'
[SubID] => 1
)
[2] => Array
(
[Desc] => 'Listed item 2'
[SubID] => 1
)
[3] => Array
(
[Desc] => 'Item with no sub category'
[SubID] => null
)
)
Would become:
Array
(
[0] => Array
(
[Desc] => 'Sub category'
[SubID] => null
[SubSections] => Array
(
[Desc] => 'Listed item 1'
[SubID] => 1
)
[2] => Array
(
[Desc] => 'Listed item 2'
[SubID] => 1
)
)
[3] => Array
(
[Desc] => 'Item with no sub category'
[SubID] => null
)
)
Sorry to be vague, I’m unsure of the best way of describing it, but hopefully the example above makes sense.
Thanks!
I think that this will do the work. Maybe some lite modification will be implied to