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.

24
  • 181
    @DTest - well yes of course it will return true because the string contains 'are'. If you are looking specifically for the word ARE then you would need to do more checks like, for example, check if there is a character or a space before the A and after the E.
    – jsherk
    Commented Nov 14, 2012 at 21:35
  • 47
    Very good comments above! I never use != or ==, after all !== and === is best option (in my opinion) all aspect considered (speed, accuracy etc).
    – Melsi
    Commented Dec 15, 2012 at 12:28
  • 11
    @jsherk Why not regexes, then? Something like " are ". Commented Jan 6, 2013 at 15:48
  • 8
    As for not catching 'care' and such things, it is better to check for (strpos(' ' . strtolower($a) . ' ', ' are ') !== false)
    – Wouter
    Commented Sep 23, 2013 at 14:26
  • 32
    I tend to avoid this issue by always using strpos($a, 'are') > -1 to test for true. From a debugging perspective, I find my brain wastes fewer clock cycles determining if the line is written correctly when I don't have to count contiguous equals signs.
    – equazcion
    Commented May 6, 2014 at 6:01