1 / 4
Computer Service
2 / 4
Networking Service
3 / 4
Web Development Service
4 / 4
Software Development Service
TNW - ICT Solutions
  • Home
  • Available Courses 
  • Available Services 
  • Website Samples 
  • Search Log In
  • 
    <?php
    $offset = 0;
    
    if(isset($_POST['text']) && isset($_POST['search']) && isset($_POST['replace'])){
     $text = $_POST['text'];
     $search = $_POST['search'];
     $replace = $_POST['replace'];
    
     $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 'Please fill all fields!';
     }
    }
    ?>
    
    <hr />
    <form action="searchandreplace.php" method="POST">
    <textarea name="text" rows="15" cols="60"></textarea><br /><br />
    Search : </br>
    <input type="text" name="search"><br /><br />
    Replace : </br>
    <input type="text" name="replace"><br /><br />
    <input type="submit" value="Submit">
    </form>