PHP Program to Count The Number of Vowels in a String

Here is a PHP program to count the number of vowels in a string "welcome".

if($a{$i}=='a'||$a{$i}=='e'||$a{$i}=='i'||$a{$i}=='o'||$a{$i}=='u') //here $a{i} will return the character for ith position
echo "The number of vowels are:-".$count;


Output: The number of vowels are:- 3

See also:

Leave a Comment