title: preg_replace within a while loop
body: <p>Why this example wont work:</p>
  
  <pre><code>$string='1000000000000';
  
  while($string=preg_replace('/(\d)((\d\d\d)+\b)/','$1,$2',$string)){}
  echo $string."&lt;br&gt;";
  </code></pre>
  
  <p>It supposed that the loop is repeated untill is not more to match.
  Untill the regex fail. But no, the loop is never ending.</p>
  
  <p>this alternative works:</p>
  
  <pre><code>$string='10000000000000';
  
  while(preg_match("/(\d)((\d\d\d)+\b)/",$string)){
      $string=preg_replace("/(\d)((\d\d\d)+\b)/","$1,$2",$string);
      }
      echo $string."&lt;br&gt;";
  </code></pre>
  
  <p>My question is:
  the preg_replace function returns some TRUE/FALSE value when the regex can't still matching?
  If return False why in the first example the loop never stop.
  Ive tried with:</p>
  
  <pre><code>while((regex)!==FALSE)
  while((regex)==TRUE)
  </code></pre>
  
  <p>and it dont work.</p>
  
  <p>I dont care about the how to put commas,
  i wanna know about the preg_replace function</p>
  
  <p>If someone can help me.
  would be great.
  thanks</p>