You are on page 1of 1

11/17/22, 1:45 PM vowel.

php

1 <html>
2 <body>
3    <h2>Find Number of Vowels in a String</h2>
4    <form action="vowel.php" method="post">
5        <input type="text" name="string" />
6        <input type="submit" />
7    </form>
8 </body>
9 </html>
10 <?php
11    if($_POST)
12   {
13        $string = strtolower($_POST['string']);
14        $vowels = array('a','e','i','o','u');
15        $len = strlen($string);
16        $num = 0;
17        for($i=0; $i<$len; $i++){
18            if(in_array($string[$i], $vowels))
19           {
20                $num++;
21           }
22       }
23         echo "Number of vowels : ".$num;
24   }
25
26 ?>

localhost:4649/?mode=php 1/1

You might also like