Showing posts with label count eight digits in php. Show all posts
Showing posts with label count eight digits in php. Show all posts

Sunday, July 30, 2017

Count eight digits in PHP

A simple program that will ask the user to give a series of numbers in integer format. Our program will count the number of eight digit occurrence based on the given number by our user. The code is written in PHP as my programming language and it is very easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.






Sample Program Output


Program Listing

<html>
  <body>
  <style>
   body {
  font-family:arial;
  font-weight:bold;
  font-size:18px;
   }
   
   #textboxid
{
font-family:arial;
font-weight:bold;
font-size:18px;
    height:25px;
    }
  </style>
  
  <?php
  $val = $_POST['value1'];
  
  if(isset($_POST['clear'])) 
$val="";
}
  ?>
   <br><br>
   <h4> Count Numbr 8 Digits in PHP </h4>
   
  <form method="post" action="">
Enter a number &nbsp;&nbsp;&nbsp;
<input id="textboxid" type="text" name="value1" value="<?php echo $val; ?>" autofocus required>
<br><br><br>
<input type="submit" name="submit" value="Ok"> &nbsp;&nbsp;&nbsp;
<input type="submit" name="clear" value="Clear">
</form>

 <?php

 function count8($num)
{
return preg_match_all("/[8]/",$num);
}

 if(isset($_POST['submit'])) 
    echo "<br><br>";
echo "The number of 8 digits is " .count8($val).".";
}

?>
 </body>
 </html>