note 100498 deleted from function.number-format by danbrown

From: Date: Wed, 20 Oct 2010 03:26:53 +0000
Subject: note 100498 deleted from function.number-format by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173293@lists.php.net to get a copy of this message
Note Submitter: Gilton Guma ---- /* Formata numeros SEM e com arredondamento Parametros: [a] -> Numero [b] -> Casa Decimais [0] [c] -> Separador Milhares [d] -> Separador Decimais [e] -> Prefixo [f] -> Arredondar [true; false] (Padrão: false) */ function Num_Format($a, $b = 0, $c = "", $d = "", $e = NULL, $f = false){ if (!$f){ $t = "0."; for ($i = 1; $i <= ($b - 1); $i++) $t .= "0"; $t .= "1"; $a = round(((($a * 2) - $t) / 2), $b); } $ret = number_format($a, $b, $c, $d); if ($e) $ret = $e.$ret; return $ret; } $numero = 12345.6789; echo "<b>Normal:</b> ".$numero; echo "<hr />"; echo "<b>Sem arrendamento:</b> ".Num_Format($numero, 2, ",", ""); echo "<br />"; echo "<b>Com arrendamento:</b> ".Num_Format($numero, 2, ",", ".", NULL, true); echo "<hr />"; echo "<b>Sem arrendamento 4 casas e prefixo:</b> ".Num_Format($numero, 4, ",", ".", "R$"); echo "<br />"; echo "<b>Com arrendamento 4 casas e prefixo:</b> ".Num_Format($numero, 4, ",", ".", "R$");

« previous php.notes (#173293) next »