Tuesday, 11 August 2015

How To Count Vowel And Consonant In Php

In This Program, we will Find Vowel and Consonant.
"How to count Vowel and Consonant" This is the important program in PHP. Copy this program and save it as any name but with a .php extension, and run it on your WAMP or XAMP server. If You Need Any Help Comment Below.

PHP script vowels from string count number of vowels in php

PHP script to find number of vowels in a string

<title> Vowels and Consonants Counter</title>
body {


$values = $_POST['value'];
if(isset($_POST['check'])) {

  if ($values==" ") {
      echo "<script>";
     echo "alert('It Cannot Be Empty!!! Please enter a sentence.');";
     echo "</script>";
     $values=" ";
     $results=" ";
 if ($values != " ") {
   $total_vowels = 0; $total_consonants=0;

      $vowels = Array('a','e','i','o','u','A','E','I','O','U');
      $vowels = Array('a','e','i','o','u','A','E','I','O','U');
      $consonants = Array('b','c','d','f','g','h','j','k','l','m'

for ($b=0;$b<strlen($values);$b++)
    for ($a = 0;$a<10;$a++)
        if ($values[$b] == $vowels[$a])

 for ($a = 0;$a<42;$a++)
        if ($values[$b] == $consonants[$a])
   $results .=  "==== REPORT ==== ";
   $results .=  "<br><br>";
   $results .= "The sentence is   :=>   " .$values."<br><br><br>";
   $results .= "Total Consonants  :=>  " .$total_consonants."<br>";
   $results .=  "Total Vowels     :=>  " .$total_vowels."<br>";



if(isset($_POST['clear'])) {
  $values=" ";
  $results= " ";


<body style='background-color: #FF00DD>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Vowels and Consonants Counter</h2>
<form action="" method="post">
 Enter a Sentence : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=50/>
   <input type="submit" name="check" value="Find Vowels and Consonants"
  title="Click here to know the number of Vowels and Consonants in a given sentence."/>
  <input type="submit" name="clear" value="Clear"
  title="Click here to clear text box and values on the screen"/>
echo $results;

If You Found This Program Helpful Leave A Comment And Do Share With Your Friends.

You May Also Like:-
Palindrome Number In Php
How To Find Armstrong Number In Php


Post a Comment