find and replace
Posted: Mon Feb 06, 2012 2:37 pm
hi,could you plase say what is wrong .when i click submit button nothing happens
Code: Select all
<?php
$offset=0;
if(isset($_POST['text']) && isset($_POST['search']) && isset($_POST['replace']) )
{
$text=$_POST['text'];
$src=$_POST['search'];
$rplc=$_POST['replace'];
$search_len=strlen($src);
if(!empty($text) && !empty($src) && !empty($rplc) )
{
while($strpos=strpos($text,$src,$offset))
{
echo $offset=$strpos+$str_len.'<br>';
}
}
else
{
echo "fill all the fields";
}
}
?>
<form action="index.php" method="post">
<textarea name="text" cols="30" rows="6"></textarea><br><br>
Search For : <input name="search" type="text"><br>
ReplaceWith : <input name="replace" type="text"><br><br>
<input name="submit" type="submit" value="FindAndReplace"><br>
</form>