0

I have got this php code

$Likes=1112;
$Likes=$Likes/1000;
echo $Likes."k";

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

lIP TT
  • 77
  • 1
  • 6

1 Answers1

1

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!

FirstOne
  • 6,033
  • 7
  • 26
  • 45
csabinho
  • 1,579
  • 1
  • 18
  • 28