-
Notifications
You must be signed in to change notification settings - Fork 1
/
fns.php
36 lines (27 loc) · 854 Bytes
/
fns.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$offset=0;
if(isset($_POST['text'])&& isset($_POST['searchfor'])&&isset($_POST['replacewith'])){
$text =$_POST['text'];
$search =$_POST['searchfor'];
$replace =$_POST['replacewith'];
$search_length = strlen($search);
if(!empty($text)&& !empty($search)&& !empty($replace)){
while($strpos =strpos($text,$search,$offset)){
$offset = $strpos + $search_length;
$text = substr_replace($text,$replace,$strpos,$search_length);
echo $text;
}
}else{
echo 'fill all details complete';
}
}
?>
<hr>
<form action ="fns.php" method ="POST">
<textarea name="text" rows="6" cols="30"></textarea><br><br>
Search for:<br>
<input type="text" name ="searchfor"><br><br>
Replace with:<br>
<input type="text" name ="replacewith"><br><br>
<input type="submit" value = "Find and Replace">
</form>