How to replace a string from a default position?
<p>I have a sample code:</p>

<pre><code>$text = "abc def abc jkl mno";
    $regex = '/'.trim('abc').'/ism';
    $search = array();
    if(preg_match_all($regex, $text, $tmp)) {
       if(isset($tmp[0])) {             
          for($i = 0;$i &lt; count($tmp[0]); $i++) {
            $search = $tmp[0][1];
            $replace = 'ghi';
            $article = str_replace($search, $replace, $text);   
          }
       }
    }
        echo $article;
</code></pre>

<p>When i echo $article_text is result is: <strong>ghi</strong> def <strong>ghi</strong> jkl mno</p>

<p>But I want result is abc def <strong>ghi</strong> jkl mno , how to fix it</p>
