168. PHP Program to delete particular word from the given line of text.
How does this program work?
- This program is used to delete particular word from the given line of text using PHP.
Here is the code
<html>
<head>
<title>PHP Program To delete particular word from the given line of text</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="name1" value="" placeholder="Enter string"/> </td>
</tr>
<tr>
<td> <input type="text" name="name2" value="" placeholder="Enter delete word"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])) {
$str = $_POST['name1'];
$s1 = $_POST['name2'];
echo "Original string is : ".$str."</br>" ;
echo "After deleting the new string is : ".str_replace($s1,'', $str);
}
?>
</body>
</html>