DEV Community

Discussion on: Daily Challenge #3 - Vowel Counter

Collapse
 
peter279k profile image
peter279k

Here is my simple solution with PHP:

function getCount($str) {
  $vowelsCount = 0;

  $vowels = ['a', 'e', 'i', 'o', 'u'];

  $index = 0;
  for(; $index < mb_strlen($str); $index++) {
    if (in_array($str[$index], $vowels)) {
      $vowelsCount += 1;
    }
  }

  return $vowelsCount;
}