note 39828 added to function.substr
| From: | tim_hunter at linuxmail dot org | Date: | Thu, 12 Feb 2004 02:29:06 +0000 |
| Subject: | note 39828 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65033@lists.php.net to get a copy of this message | ||
Sempre esperamos encontrar um tipo de formatação como essa, e aí está
<? php
//Para formatar número em formato brasileiro
$valor=123456.457
$novoformato = number_format($number, 2, ',', '.');
echo $novoformato; // irá mostrar 123.456,46
// se vc quiser o "R$"
$numerocomcifrao = "R\$ $novoformato" // irá retornar "R$ 123.456,46
//para formatar CEP
function cep($valor){
$cep1 = substr($valor, 1 , 5); // retorna "abcde"
$cep2 = substr($valor, -3); // retorna "fgh"
$cep = $cep1.$cep2; // retorna "abcde-fgh"
return $cep;
};
?>
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39828
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39828&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39828&report=yes
Search -- http://master.php.net/manage/user-notes.php