Welcome Guest, Not a member yet? Register   Sign In
Having trouble with a foreach loop
#1

Hi there,

I am trying to figure out why I am getting either undefined index error or non-object error.

PHP Code:
private function checkForBot(){
 
      
       $keywords 
$this->Content_model->get_results('analytics_bots');
 
      $agent strtolower($_SERVER['HTTP_USER_AGENT']);
 
      foreach ($keywords->keyword as $key) {
 
          if(strpos($agent$key) !== false){
 
          return true;
 
                
       
}
 
      return false;
 
   

if I use $keywords->keyword I am getting the non-object and if I use $keywords['keyword']I get the index error.

I just cannot figure out why its not accepting the array in.

Thanks,

Doomie
Reply


Messages In This Thread
Having trouble with a foreach loop - by doomie22 - 09-15-2016, 06:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB