I\'ve been looking a lot of answers, but none of them are working for me.
This is the data assigned to my $quantities array:
Array(
The following function worked for my case. We can use a simple recursive function to remove all empty elements from the multidimensional PHP array:
function array_filter_recursive($input){
foreach ($input as &$value){
if (is_array($value)){
$value = array_filter_recursive($value);
}
}
return array_filter($input);
}
Then we just need to call this function:
$myArray = array_filter_recursive($myArray);