Count Vowels
PHP
Easy
5 views
Problem Description
Count vowels (a,e,i,o,u) in the string, case-insensitive.
Input Format
One line string s.
Output Format
One integer count.
Official Solution
<?php
$inputText=rtrim(stream_get_contents(STDIN));
if($inputText==='') exit;
$inputText=strtolower($inputText);
$c=0;
for($i=0,$n=strlen($inputText);$i<$n;$i++){
$ch=$inputText[$i];
if($ch==='a'||$ch==='e'||$ch==='i'||$ch==='o'||$ch==='u') $c++;
}
echo $c;
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!