How can we format a number as “22.00″ in php ?

April 11, 2010 | Filed Under PHP | Comments Off

using  number_format() function.

<?php

$number = 1234.56;

// english notation (default)
$english_format_number = number_format( style=”color: #0000bb;”>$number);
// 1,235

// French notation
$nombre_format_francais style=”color: #007700;”>= number_format($number, 2, style=”color: #dd0000;”>’,’, ‘ ’);
// 1 234,56

$number = 1234.5678;

// english notation without thousands seperator
$english_format_number = number_formatviagra order style=”color: #007700;”>($number, 2, ‘.’, );
// 1234.57

?>

Comments

Comments are closed.

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker