Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 9
    A note on the php.net/manual/en/function.strstr.php page: Note: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.
    – Jo Smo
    Commented Feb 8, 2014 at 17:49
  • @tastro Are there any reputable benchmarks on this?
    – user399666
    Commented Jun 17, 2014 at 10:26
  • This might be slower, but IMHO strstr($a, 'are') is much more elegant than the ugly strpos($a, 'are') !== false. PHP really needs a str_contains() function. Commented Mar 15, 2018 at 10:57
  • It blows my mind that this is not the accepted answer
    – kurdtpage
    Commented Jan 15, 2020 at 3:03