Press "Enter" to skip to content

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:

Vinish Kapoor

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *