1

Hey guys my question is simple how can i check if a word contains a series of characters.

Exemple : Check if IAmATest as Test in it ... ?

Test@gmail.com --> gmail.com = true

Test@Yahoo.eu --> gmail.com = false

kix
  • 3,290
  • 27
  • 39
  • 1
    Have a look at this function http://php.net/manual/en/function.strpos.php – Eakethet Aug 28 '18 at 12:56
  • 1
    If you want to do more complex stuff take a look at http://php.net/manual/fr/function.preg-match.php instead of many if/elseif conditions – Mcsky Aug 28 '18 at 13:18
  • Possible duplicate of [How do I check if a string contains a specific word?](https://stackoverflow.com/questions/4366730/how-do-i-check-if-a-string-contains-a-specific-word) – Xatenev Aug 28 '18 at 15:13

1 Answers1

0
if (strpos('Test@gmail.com', 'gmail.com') !== false) {
    // word contains characters
} else {
    // word doesn't contains characters
}
smottt
  • 3,272
  • 11
  • 37
  • 44
Bart
  • 1,268
  • 2
  • 12
  • 14