Gerçek sayılar, örneğin 12.92 için olacağını istiyorum, ama 12,9241. Böyle yapmak mümkün mü?
PHP, try number_format
:
$n = 1234.5678;
// Two decimal places, using '.' for the decimal separator
// and ',' for the thousands separator.
$formatted = number_format($n, 2, '.', ',');
// 1,234.57
PHP sizin için number_format()
, MySQL için FORMAT()
işlevini kullanabilirsiniz kullanabilirsiniz.
MySQL: http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_format
FORMAT(number, 2)
Örnek:
mysql> SELECT FORMAT(12332.123456, 4);
-> '12,332.1235
PHP: http://php.net/manual/en/function.number-format.php
$number = 1234.5678;
$formatted_number = number_format($number, 2, '.', '');
// 1234.56
Sen, 100 ile numaranızı çarpın sonucu bir yuvarlama yapmak ve sonra 100 ile geri bölebilirsiniz.
Veya php yuvarlak işlevi kullanmak round function
$result=round(12.9241, 2);