Answers for "php only use decimal place if needed"

PHP
5

php parse float 2 decimal places

$num = 5;
$num = number_format($num, 2);
Posted by: Guest on June-18-2021
1

php echo number with decimal

<?php

$number = 1234.56;

// english notation (default)
$english_format_number = number_format($number);
// 1,235

// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56

$number = 1234.5678;

// english notation without thousands separator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57

?>
Posted by: Guest on June-07-2021

Code answers related to "php only use decimal place if needed"

Browse Popular Code Answers by Language