Created
November 8, 2018 13:32
-
-
Save tounsils/6269a9429f15767b01820ab4de0af7bb to your computer and use it in GitHub Desktop.
Displays vowels and number of vowels in a string using regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$str = "Created by PhpStorm. | |
* User: Tounsi | |
* Date: 30/10/2018 | |
* Time: 11:59 | |
* | |
* List of vowels in string"; | |
$nbVowels = 0; | |
for($i=0;$i<strlen($str);$i++) | |
{ | |
$letter = $str[$i]; | |
if(preg_match('/[aeuioAEUIO]/',$letter)){ | |
$nbVowels++; | |
echo $letter; | |
} | |
} | |
echo "<br>number of vowels = $nbVowels :)"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment