How to show a number with two decimal places in PHP

1 Answer

0 votes
$num = 20 / 35 * 100;

echo $num . "\n";

echo number_format((float)$num, 2, '.', '');

  
  
 
  
/*
run:
  
57.142857142857
57.14
  
*/

 



answered May 23, 2022 by avibootz

Related questions

1 answer 153 views
1 answer 170 views
3 answers 396 views
1 answer 313 views
1 answer 242 views
...