163. PHP Program to find number of blank spaces from the given text.
How does this program work?
- This program is used to find number of blank spaces from given text using PHP.
Here is the code
<html>
<head>
<title>PHP Program To find number of blank spaces from given text</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter a String"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])) {
$s1 = $_POST['num1'];
$space = substr_count($s1," ");
//to count white spaces
echo "Given string: ".$s1."</br>";
echo 'Total Blank spaces :'.$space;
return 0;
}
?>
</body>
</html>