In codeigniter, in my controller file, I fetch data from model. To validate the results I use foreach loop and there is no problem. But instead of using foreach I want to use in_array() to control if variable is in database result array or not . Here is code :
function _remap($method,$params = array()){
//in construct, I use $this->model
if (isset($params[0])) {
$this->db->distinct('*****');
$this->db->from('*****');
$this->db->where('****',****);
$query = $this->db->get();
if (in_array($params[0],$query->results())) {
echo "in_array works";
}
}
But not echoing anything. How can I do it?Thanks.
.get()return anobjectorarray?result_array()to return a pure array and then try usingin_array