I am using Laravel 5.3
.
I have a multidimensional array
like:
Array
(
[id] => 37141
[last_done_on] => []
[children] => Array
(
[0] => NULL /* This must be removed */
[1] => Array
(
[id] => 37142
[last_done_on] => Array()
[children] => Array()
)
[2] => Array
(
[id] => 37143
[last_done_on] => Array()
[children] => Array
(
[0] => Array
(
[id] => 37144
[last_done_on] => Array()
[children] => Array()
)
[1] => Array
(
[id] => 37145
[last_done_on] => Array()
[children] => Array()
)
)
)
[3] => Array
(
[id] => 37157
[last_done_on] => Array()
[children] => Array
(
[0] => Array
(
[id] => 37158
[last_done_on] => Array()
[children] => Array()
)
[1] => Array
(
[id] => 37159
[last_done_on] => Array()
[children] => Array
(
[0] => NULL /* This must be removed */
)
)
)
)
)
)
And I want to remove
the elements
that are NULL
. So the result should be like:
Array
(
[id] => 37141
[last_done_on] => []
[children] => Array
(
[0] => Array
(
[id] => 37142
[last_done_on] => Array()
[children] => Array()
)
[1] => Array
(
[id] => 37143
[last_done_on] => Array()
[children] => Array
(
[0] => Array
(
[id] => 37144
[last_done_on] => Array()
[children] => Array()
)
[1] => Array
(
[id] => 37145
[last_done_on] => Array()
[children] => Array()
)
)
)
[2] => Array
(
[id] => 37157
[last_done_on] => Array()
[children] => Array
(
[0] => Array
(
[id] => 37158
[last_done_on] => Array()
[children] => Array()
)
[1] => Array
(
[id] => 37159
[last_done_on] => Array()
[children] => Array
(
)
)
)
)
)
)
How to do this?