lundi 23 novembre 2020

How to check/find if multiple letters are in a string | PHP

So far, I managed to find if ONE letter is in ANY given string. However, I cannot manage to ask for multiple conditions like 'a' && 'e' && 'i'... In a way that all of those letter need to be in the string so the echo "Vowel found" gets out.

I have tried with stristr, strpos... and so far my best guess was deprecated so I couldn't use it. My last resource, which didn't work anyway, was to nest if conditions to make it work; also tried with arrays with no positive result.

$string = 'murcielago'; // a word with 5 vowels
  if(stristr($string, 'a') == TRUE) {
    echo 'Vowel found';

  } else {
      echo "Vowel not found";
  };
´´´
This is my code for ONE string or letter to be found in the original given string.
Thanks for your time.

Aucun commentaire:

Enregistrer un commentaire