Add exam54 files to Git
This commit is contained in:
33
exam54/FindAndReplace.php
Executable file
33
exam54/FindAndReplace.php
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
<?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)){
|
||||||
|
|
||||||
|
$text = str_ireplace($search, $replace, $text);
|
||||||
|
echo $text;
|
||||||
|
}else{
|
||||||
|
echo 'Please fill in all fields.';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="FindAndReplace.php" method="POST">
|
||||||
|
<textarea name="text" cols="30" rows="7"></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>
|
||||||
Reference in New Issue
Block a user