Right to the point. I have a form that submits a multidimensional array of values. Usually it gets something like this.
[0] => Array
(
[socialClass] => Myclass
[socialLink] => http://...
[socialName] => Name
)
[1] => Array
(
[socialClass] =>
[socialLink] => MyClass
[socialName] => Name
)
[2] => Array
(
[socialClass] =>
[socialLink] =>
[socialName] =>
)
The idea es to remove incomplete arrays from the tree, like [1]
and [2]
, so i would return like this after the filter.
[0] => Array
(
[socialClass] => Class
[socialLink] => http://...
[socialName] => Name
)
array_filter
doesn't work in this case, and other "recursive" custom made functions either. How can I do it?
The following
array_filter
call with a custom filter function should do the trick for you:You'll note that the item will be removed if any of its sub-array values is the empty string.