164. PHP Program to find number of words from the given text.
How does this program work?
- This program is used to find number of words from given text using PHP.
Here is the code
<html>
<head>
<title>PHP Program To find number of words 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'];
$word = str_word_count($s1);
//To count number of words
echo "Given string: ".$s1."</br>";
echo 'Number of Words in a string is :'.$word;
return 0;
}
?>
</body>
</html>