How to remove empty values from multidimensional array in PHP?

前端 未结 8 2318
梦如初夏
梦如初夏 2020-12-06 11:47

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(
             


        
8条回答
  •  北海茫月
    2020-12-06 12:26

    Bit late, but may help someone looking for same answer. I used this very simple approach to;

    1. remove all the keys from nested arrays that contain no value, then
    2. remove all the empty nested arrays.

    $postArr = array_map('array_filter', $postArr);
    $postArr = array_filter( $postArr );
    

提交回复
热议问题