Here is an array. Once a new element comes in with parent_uuid, I need to add that to the corresponding position, that is to the children of the item which has uuid value as parent_uuid value. The children then can have other children and if that is specified, I need to insert it to the particular parent. I think for this I need to search to the multidimensional array with the parent_uuid value. How can I do this and insert in PHP?
Array
(
[0] => Array
(
[id] => 1
[uuid] => ef4b72ae-012a-4b2c-88b2-d4bf8726fcb9
[parent_uuid] =>
[name] => First Parent
[children] => Array
(
)
)
[1] => Array
(
[id] => 2
[uuid] => 74bd4b37-6a20-4579-99a3-ce56b0bc28a7
[parent_uuid] =>
[name] => Second Parent
[children] => Array
(
[0] => Array
(
[id] => 3
[uuid] => f87c6d5c-93ec-40bf-a04d-c925dd1e0aca
[parent_uuid] => 74bd4b37-6a20-4579-99a3-ce56b0bc28a7
[name] => First Child
[children] => Array
(
)
)
[1] => Array
(
[id] => 4
[uuid] => cb2b3d9d-867c-40a0-9254-05b466859db1
[parent_uuid] => 74bd4b37-6a20-4579-99a3-ce56b0bc28a7
[name] => Second Child
[children] => Array
(
)
)
)
)
)