title: Error : Warning: strpos() [function.strpos]: Offset not contained in string - can not find solution
body: <p>I know, this question has been asked, but unfortunately, there are no answers how to solve this problem.</p>
  
  <p>This appears in my logfiles:</p>
  
  <p><strong>PHP message: PHP Warning:  strpos(): Offset not contained in string in ... on line 479</strong></p>
  
  <p>Unfortunately, I can not understand what causes this problem and how to fix it. I tested this function many times (with large $text, with short $text, with $spam words and without $spam words) but I never get this error. So, what kind of texts my users submit that cause this error? </p>
  
  <pre><code>    if (strposab($text, $spam, 1)) {
      echo "Email addresses and URLs not allowed here";
  die;
      }
  
  $spam = array('http','www','hotmail','yahoo','gmail','msn');
  
  
  function strposab($haystack, $needles=array(), $offset=0) {
  $chr = array();
  foreach($needles as $needle) {
  $res = strpos($haystack, $needle, $offset);
  if ($res !== false) $chr[$needle] = $res;
  }
  if(empty($chr)) return false;
  return min($chr);
  } 
  </code></pre>
  
  <p><strong>Second question:</strong></p>
  
  <p>For some reason this function does not filter the first word of the string.
  For example in this string function does not find word "hotmail":</p>
  
  <pre><code>$text = 'hotmail test test test test';
  </code></pre>
  
  <p>but in this string it finds word " hotmail":</p>
  
  <pre><code>$text = 'test hotmail test test test test';
  </code></pre>