177. PHP Program to work as strchr() function.
How does this program work?
- In this program you are going to learn about how to works as strchr() function in PHP.
Here is the code
<html>
<head>
<title>PHP Program To works as strchr() function</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num" value="" placeholder="Enter String"/> </td>
</tr>
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter Starting word"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])) {
$str = $_POST['num'];
// Search string where you want to start the string
$search = $_POST['num1'];
//To print Original String
echo "The Original String is : ".$str."</br>";
// It is used to find the position of the first occurance of string
$ch = strchr($str, $search);
echo "The String Starting from $search is : ".$ch;
}
?>
</body>
</html>