PHP Count round thousand to a K style count like facebook Share . . . Twitter Button ect
<p>Ok so I am trying to turn my hit counter to round thousands to a single digit too display 3 thousand hits as 3K for example, like the Facebook Share and Twitter Tweet Buttons do. Here is my code. Any idea what I am doing wrong?</p>

<pre><code>$postresultscount = (($resultscount) ? $resultscount-&gt;sumCount : 1);
$k = 1000;
$L = '';
if ($postresultscount &gt; $k) {
    $echoxcount = round($postresultscount/$k);
    $L = 'K';
} else if ($postresultscount == $k) {
    $echoxcount = 1;
    $L = 'K';
} else {
    $echoxcount = $postresultscount;
}

echo 'document.write("'.$echoxcount.' '.$L.'")';
</code></pre>
