Ajax DataGrid Support Product Page

Number formatting :: 2 decimal places...

Asked 03 Feb 2011 17:10:57
1
has this question
03 Feb 2011 17:10:57 reinhardt ellis posted:
This is what ihave in my custom library..
how do i get the numberforatting to be 2 decimal places...

thank you


eg.

1000,412.12

<?php

// Temp. fix ///////////////////////////////////////////////
$c = array();
foreach ($columns as $col) {
	if (substr($col[0], 0, 1) == '`')
		$col[0] = substr($col[0], 1);
	if (substr($col[0], -1) == '`')
		$col[0] = substr($col[0], 0, -1);
	$c[] = $col;
}
$columns = $c;
////////////////////////////////////////////////////////////

function numberformatting($colVal = 0) {
	return strval(number_format((float) $colVal));
}
?>


Edited by - reinhardt ellis on 03 Feb 2011  17:13:01

Replies

Replied 03 Feb 2011 17:43:49
03 Feb 2011 17:43:49 reinhardt ellis replied:
Solution



function numberformatting($colVal = 0) {
	return strval(number_format((float) $colVal, 2, '.', ','));
}


Replied 03 Feb 2011 17:44:56
03 Feb 2011 17:44:56 Teodor Kuduschiev replied:
As discussed in the live support chat, please check this link: php.net/manual/en/function.number-format.php

Reply to this topic