如何在codeigniter中检查数组的值

时间:2013-04-26 12:49:22

标签: arrays codeigniter

$result=array();
$count = count($days);
for($i=0;$i<$count-1; $i++)
    {   
    $bookDate = $days[$i];
    $fromDate = $this->booking_model->Get_BookedDate($bookDate,$roomname);                                      
    if ($fromDate != 0)
    {
        $result[] = $bookDate;  
    }                   
}
return $result; 

这是我的codeigniter控制器函数,我想检查$ fromDate的值是否为零。我正在获得像这样的数组

 Array ( [0] => Array ( ["2013-04-27" between fromDate and toDate] => 1 ) )   

我对codeigniter很新。谢谢你的帮助。

3 个答案:

答案 0 :(得分:2)

         $result=array();
         $count = count($days);
         for($i=0;$i<$count-1; $i++)
            {   
$bookDate = $days[$i];
$fromDate = $this->booking_model->Get_BookedDate($bookDate,$roomname);                                                      
if (!empty($fromDate[0]['"'.$bookDate.'" between fromDate and toDate']))
        {
        $result[] =$bookDate;   
        }                                                                   
              }
     return $result;

试试这个.IT可以帮到你

答案 1 :(得分:0)

使用empty()功能。

if(!empty($fromdate)) { //if $formdate is empty or 0 or false the loop won't be executed
  //Your code.
}

答案 2 :(得分:0)

if (!empty($fromDate))
               {
            $result[] = $bookDate;  
        }

试试这个。