Cannot format the number_format
<p>I'm working on a website, where the weight should be shown. My clients want me to show the weight of the tool. But the real problem is, if the weight of tools is below 1 Kg, then it must show only 3 digit of fractions. But if the weight exceeds 1 kg, then it must show only the decimal numbers.I don't know how to do it using number format. I'm so confused about it. Please help me. I'm a budding php developer. I did this to get the weight above 1 kg. But don't know what to what logic to use to display only the grams i,e 200grams. Not 0.200 Kg</p>

<pre><code>&lt;?php $_weight = $_product-&gt;getweight()?&gt;
&lt;?php if ($_weight &gt; 1) ?&gt;
&lt;span&gt;&lt;?php echo(round($_weight))?&gt;Kg&lt;span&gt;
</code></pre>
