0

In a sql table double floating number like

145.00000000, 2.00000000, 23.12000000, 12.02400000, 0.026, 0.5402,

how i can do these numbers without decimal 0 like with php

145, 2, 23.12, 12.024, 0.026, 0.5402,

Prabu R
  • 65
  • 1
  • 9
  • http://stackoverflow.com/questions/2938296/remove-trailing-zeros-from-decimal-in-sql-server – Sarajog Jul 22 '13 at 10:55
  • You can format the number either in SQL or in PHP, but you don't need both. So if you would search a solution for either, you're much more likely to find it. – GolezTrol Jul 22 '13 at 11:02

1 Answers1

0

Just cast to float in PHP and it will strip the trailing zeros:

$float = '145.00000000';
echo (float)$float; // 145

$float = '23.12000000';
echo (float)$float; // 23.12
bitWorking
  • 12,485
  • 1
  • 32
  • 38