How to format numbers by inserting a space between each group of three digits?
<p>I use preg replace to separate numbers by inserting a space between each group of three digits:</p>

<pre><code>$alexa_rank_raw = 8389876;

$alexa_rank = preg_replace("/(\d{3})/", '$1.', $alexa_rank_raw);

// alexa rank becomes: 838.987.6
</code></pre>

<p>How can I do the replace so the final number would look like this:</p>

<p><strong>8.389.876</strong></p>

<p>Any ideas?</p>
