2010-01-02 13 views

उत्तर

23

पीएचपी में, 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 
4

पीएचपी के लिए आप number_format() उपयोग कर सकते हैं, MySQL के लिए FORMAT() समारोह का उपयोग करें।

MySQL: http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_format

FORMAT(number, 2) 

उदाहरण:

mysql> SELECT FORMAT(12332.123456, 4); 
     -> '12,332.1235 

पीएचपी: http://php.net/manual/en/function.number-format.php

$number = 1234.5678; 
$formatted_number = number_format($number, 2, '.', ''); 
// 1234.56 
+2

तुम भी एक ही फैशन में ROUND() का उपयोग कर सकते है अगर आप हजारों सीमांकक नहीं करना चाहते का उपयोग करें। –

-1

आप 100 से अपना नंबर गुणा कर सकते हैं, परिणाम और उसके बाद विभाजन की एक पूर्णांकन कर 100 से पीछे।

या php में दौर समारोह round function

$result=round(12.9241, 2); 
संबंधित मुद्दे