179. PHP Program to work as strspan() function.
How does this program work?
- In this program you are going to learn about how to works as strspan() function in PHP.
Here is the code
<html>
<head>
<title>PHP Program To works as strspan() function</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="name1" value="" placeholder="Enter 1st string"/> </td>
</tr>
<tr>
<td> <input type="text" name="name2" value="" placeholder="Enter 2nd string"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])) {
$n1 = $_POST['name1'];
$n2 = $_POST['name2'];
//Return the number of characters found in the string "n1"
//That contains the characters "n2"
$length = strspn($n1, $n2);
echo "First String : ".$n1."</br>";
echo "Second String : ".$n2."</br>";
echo "Number of characters found in the string is: " .$length;
}
?>
</body>
</html>