删除php数组中的空值

my DB as follows,

date        income expenses maincat
2015-02-06  10000           salary
2015-02-05         500      bank charges
2015-02-05         300      rent
2015-02-01  500             bonus

and i'm using following sql query to get DB values.

$sql= mysqli_query($con,"SELECT maincat as label,income as value FROM transaction where date BETWEEN '$date1' AND '$date2' AND email='$user' GROUP BY maincat") or die ("error3");

and it goes though following php query,

$arr = array();
While($row1 = mysqli_fetch_assoc($sql)){
     $arr[] = $row1;
} 
$ar = array_values($arr);

and it gives out put like this,

[{"label":"income","value":"10000"},{"label":"bank charges","value":""},{"label":"rent","value":""},{"label":"bonus","value":"500"}]     

and I'm passing that values to java script(Morris.js) to show it in the donut chart. but it doesn't work. when there values as,

 [{"label":"income","value":"10000"},{"label":"bonus","value":"500"}] 

it works fine.i cant put "" values as "0" because there is no actual income as "bank charges" or "rent" (they are expenses) is there any method to remove this empty values ({"label":"bank charges","value":""} ) from above and get out put as,

 [{"label":"income","value":"10000"},{"label":"bonus","value":"500"}] 

and my morris.js code as follows,

<script>
                        Morris.Donut({
                          element: 'donut',
                          resize : true,
                          data   : <?php echo json_encode($ar); ?>,
                            backgroundColor: '#0011',
                            labelColor: 'black',
                            colors:[
                                    '#A4A4A4','#FE2E64','#0B610B','#0B615E',
                                    '#FF8000','#088A68','#4B8A08','#A9D0F5',
                                    '#5F4C0B','#F3F781','#81BEF7','#04B431',
                                    '#D7DF01','#BE85F7','#BE59F7','#BE81F7',
                                    '#F4FA58','#0431B4','#D8D8D8','#4C0B5F',
                                    '#086A87','#F7D358','#DF7401','#B18904',
                                    '#045FB4',                              
                            ],
                        });
                    </script>

thank you..

Why not just use a loop to filter the empty items?

$legalArray = array();
foreach($ar as $item){
    if(is_numeric($item['value']))
        $legalArray[] = $item;
}

Output the $legalArray.

You should check you sql code

SELECT maincat as label,income as value FROM transaction where date BETWEEN '$date1' AND '$date2' AND email='$user' AND label != '' AND value != '' GROUP BY maincat"

May have my query wrong think there is a better way of putting that,

also you can use php to do the check

While($row1 = mysqli_fetch_assoc($sql)){
if (!empty($row1['label']) && !empty($row1['value']))
    $arr[] = $row1;
}