How to print double data with commas into specific format in PHP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to print double data with commas into specific format in PHP

I have number with double datatype like these : 1.59870 and 0.000000 how possible way to echo it in php to : 1.59870 to became 1.5 and 0.000000 became only 0. any help will appreciated. thanks.

7th May 2018, 12:45 PM
Muhamad Anggayani
Muhamad Anggayani - avatar
1 Answer
+ 4
You can use number_format function for that purpose, here's a link to the function reference: http://php.net/manual/en/function.number-format.php
10th May 2018, 4:41 PM
Ipang