title: while loop doesn't work properly,why?
body: <p>It keeps (echo)ing sth.</p>
  
  <pre><code>&lt;?php
  $offset=0;
  if (isset( $_POST['text']) &amp;&amp; isset( $_POST['search_for']) &amp;&amp;    isset($_POST['replace'])){
       $text= $_POST['text'];
       $replace= $_POST['replace'];
       $search= $_POST['search_for'];
       $string_length=strlen($search);
  if (!empty ($text) &amp;&amp; !empty($search) &amp;&amp; !empty($replace)){
      while ($strpos=strpos($text,$search,$offset))
      echo $strpos.'&lt;br&gt;';
      echo $offset=$strpos+$string_length.'&lt;br&gt;';
      } else { 
       echo 'please fill all fields';
      }  
      }
      ?&gt;
  &lt;form action='index.php' method ='POST'&gt;
    &lt;textarea name='text'  rows=6 cols=30 &gt; &lt;/textarea&gt;&lt;br&gt;&lt;br&gt;
     Search for:&lt;br&gt;
     &lt;input type ='text' name='search_for'&gt;&lt;br&gt;&lt;br&gt;
     Replace with:&lt;br&gt;
     &lt;input type='text' name='replace'&gt;&lt;br&gt;&lt;br&gt;
     &lt;input type='submit' value='Find &amp; Replace'&gt;
  &lt;/form&gt;
  </code></pre>