title: Put dash between every third character
body: <p>I had a problem on how to put dash in every 3rd character. For example, I want </p>
  
  <pre><code>ABCDEF turn into ABC-DEF
  </code></pre>
  
  <p>I have this code:</p>
  
  <pre><code>$string = 'ABCDEF';
  echo substr_replace(chunk_split($string,3),'-','3','2');
  // the output is ABC-DEF
  </code></pre>
  
  <p>However this code does not work if I add more characters to the $string variable such as <code>ABCDEFGHI</code>. If I use the above code, the output will be:</p>
  
  <pre><code>ABC-DEF GHI
  </code></pre>