0

model returned a result array

public function check($date,$route){
       $query3=$this->db->query("SELECT SEAT_NO FROM TICKET WHERE ROUTE='".$route."' AND DTE='".$date."' "); 
       return $query3->result_array();
}

in controller

$data=$this->booking_model->check($date,$route);

now i need to check whether a value/string(for example "A") exist in $data array. the below code is not working.

if (in_array("A", $data)){  
   //code
}else{
   //code
}
AW Wasi
  • 29
  • 2
  • What's not working? Is 'A' actually being returned in the array? – WillardSolutions Apr 15 '16 at 19:39
  • CodeIgniter's `result_array()` returns a multi dimensional array, so `in_array()` won't work the way you are trying to use it. Have a look at [this answer](http://stackoverflow.com/a/4128377/248567) which should handle what you're after. – Kirk Beard Apr 15 '16 at 20:00

0 Answers0