lIP TT lIP TT - 1 year ago 160
PHP Question

PHP return 1 number after dot in float

I have got this php code

echo $Likes."k";

This code returns me 1.112k,but my goal is to get 1.1k

Answer Source

Use the number_format function:

echo number_format($Likes,1)."k";

And a coding style advice: don't start your variables with an upper case letter!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download