title: Echo error data using str_replace function
body: <p>I have a problem to replace a certain format with a symbol inside the number. I use below the coding to replace, but not work for me to replace the symbol, the result won't come out.</p>
  <pre class="lang-html prettyprint-override"><code>$try = &quot;100-1-1 abc/bbb&quot;;
  $try_1 = &quot;100-1-1-16 John/James&quot;;
  
  echo(replaceHyphen($try));
  echo(replaceHyphen($try_1));
  
  &lt;script&gt;
  function replaceHyphen($str) {
      $i = -1;
      for($i=0; $i &lt; strlen($str); $i++) {
          if($str[$i] == &quot;-&quot;) break;
      }
      for($i++; $i &lt; strlen($str); $i++) {
          if($str[$i] == &quot;-&quot;) $str[$i] = '/';
          if($str[$i] == &quot; &quot;) break;
      }
      return $str;
  }
  &lt;/script&gt;
  
  </code></pre>
  <p>I want the expected result like below:</p>
  <pre class="lang-html prettyprint-override"><code>100-1/1 abc/bbb
  100-/1/16 John/James
  </code></pre>
  <p>Hope someone can guide me on how to solve it. Thanks.</p>