I'm trying to delete sub array of my multidimensional array, if any of the value is empty, than delete entire sub array. I want a universal function for the same! Dont want to type specific keys. And than ReIndex the newly formed array.
My array is like
Array
(
[0] => Array
(
[name] => Test
[mobile] => 613594551
[email] => [email protected]
)
[1] => Array
(
[name] => Test1
[mobile] => 613594552
[email] => [email protected]
)
[2] => Array
(
[name] => Test2
[mobile] => 613594553
[email] => [email protected]
)
[3] => Array
(
[name] => Test3
[mobile] => 613594554
[email] => [email protected]
)
)
So if my array is
Array
(
[0] => Array
(
[name] =>
[mobile] => 613594551
[email] => [email protected]
)
[1] => Array
(
[name] => Test1
[mobile] =>
[email] => [email protected]
)
[2] => Array
(
[name] => Test2
[mobile] => 613594553
[email] =>
)
[3] => Array
(
[name] => Test3
[mobile] => 613594554
[email] => [email protected]
)
)
Than display
Array
(
[0] => Array
(
[name] => Test3
[mobile] => 613594554
[email] => [email protected]
)
)
Elaborating on Martin's answer, you can use
array_filter()
for both the source array and the nested array:Working example: https://eval.in/521449