当在yii google图表中传递一个数组元素时,它会传递null而不是值

/In view */

<?php
$nodes = $gw->searchNodes();
foreach($nodes as $node) {
 $user= $node->getpdsout();
        foreach($user as $key=>$val){
                $ls = $val['elapsed'];
                print_r($ls);//out put 16.3080555555556

                   }
}


?>

//out put :- 16.3080555555556 , but when i passed to google chart it Pass NULL , i.e first value .

//Java script file 
<div class="row">
    <div class="span6" >  
            <?php
            //very useful google chart
                    $this->widget('ext.Hzl.google.HzlVisualizationChart', array('visualization' => 'PieChart',
                     'data' => array(
                                array('Occupied ', 'Hours per Day'),
                                array('Occupied',$ls),// here got ["Occupied",null],instead of ["Occupied", 16.3080555555556]
                                array('Not Occupied', 16.3080555555556),
                                array('Occupied', 5.45388888888889),                       
                              ),
                            'options' => array('title' => 'Occupancy Sensor')));

                         ?>

                                          </div>

 </div>

out put log using fire bug:- google.visualization.arrayToDataTable([["Occupied ","Hours per Day"],["Occupied",null],["Not Occupied",16.308055555556],["Occupied",5.4538888888889]]);

Try to use var_dump instead of print_r. Sometimes you should cast some value, for example

$ls = (int) $val['elapsed'];

I will edit my answer if needed.