I have the following array format:
Array
(
[0] => stdClass Object
(
[tid] => 3
[children] => Array ()
)
[1] => stdClass Object
(
[tid] => 15
)
[2] => stdClass Object
(
[tid] => 12
[children] => Array ()
)
[3] => stdClass Object
(
[tid] => 9
[children] => Array ()
)
)
I would like to remove items that do not have [children] and am having some difficulty doing so.
Help is appreciated, thank you.
Try this, where
$arrayis the array you want to processThis will remove all items in your array where children is not set or is
null. Since in your example you set children to empty arrays, you will need to useisset()and notempty().