title: What is the fastest way to find the occurrence of a string in another string?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5820586/which-method-is-preferred-strstr-or-strpos">Which method is preferred strstr or strpos ?</a>  </p>
  </blockquote>
  
  
  
  <p>Hi!<br></p>
  
  <p>Could you tell me <b>which one is faster</b>:<br>
  <a href="http://php.net/manual/en/function.strstr.php" rel="nofollow noreferrer"><code><b>strstr</b>($mystring, $findme);</code></a>
  <br>OR<br>
  <a href="http://www.php.net/manual/en/function.strpos.php" rel="nofollow noreferrer"><code><b>strpos</b>($mystring, $findme);</code></a>
  <br>OR <i><br>
  anything else</i><br>
  <b>in finding the - first or any - occurrence of a string</b> in another one?</p>
  
  <p>Does it even matter in performance if I check the occurrence in a case-insensitive mode with <a href="http://www.php.net/manual/en/function.stristr.php" rel="nofollow noreferrer"><code>stristr()</code></a> OR <a href="http://www.php.net/manual/en/function.stripos.php" rel="nofollow noreferrer"><code>stripos()</code></a>?</p>
  
  <p>In my case it doesn't matter in which exact position the given string is (if any), or how many times it occurs in the other one (if any), the only important question is if it even exists in the other string.</p>
  
  <p>I've already found some comments about differences of speed in various articles (e.g. <a href="http://php.net/manual/en/function.strstr.php" rel="nofollow noreferrer">on php.net</a>, someone says strstr() is faster in case there is a !== false check after strpos), but now I can't decide which is true.</p>
  
  <p>If you know about any better methods of searching a string in another, please let me know!</p>
  
  <p>Thank you very much for the relevant comments!</p>
  
  <p>============</p>
  
  <h3>An example:</h3>
  
  <pre>
  <code>
  $mystring = 'blahblahblah';  
  $findme = 'bla';  
  
  if(strstr($mystring, $findme)){  
     echo 'got it';  
  }  
  else{  
     echo 'none';  
  }  
  
  echo PHP_EOL;
  
  if(strpos($mystring, $findme) !== false){  
     echo 'got it';  
  }  
  else{  
     echo 'none';  
  }  
  
  </code>
  </pre>