• support@answerspoint.com

Check if string contains specific words?

Packers and Movers in Patna


$a = 'How are you?';
if ($a contains 'are')
    echo 'true';

Suppose I have the code above, what is the correct way to write the statement if ($a contains 'are')?



You can use the strpos function which is used to find the occurrence of one string inside other:

if (strpos($a,'are') !== false) {
    echo 'true';
  • answered 6 years ago
  • Sandy Hook

Packers and Movers in Patna

Your Answer

    Facebook Share        
  • asked 6 years ago
  • viewed 1289 times
  • active 6 years ago

Best Rated Questions