Strona 1 z 1

Re: [PHP] Wyświetlanie zmiennych

: ndz kwie 02, 2006 8:47 am
autor: Cotter
załóżmy, że w $cena jest cena
[php]<?php
$cena = 4.5;
$tab = explode(".",$cena);
$cena = $tab[0];
if ($tab[1] == null)
$tab[1] = "00";
if (strlen($tab[1]) == 1)
$tab[1] = $tab[1]."0";
$cena = $tab[0].".".$tab[1];
print $cena;
?>[/php]

Re: [PHP] Wyświetlanie zmiennych

: ndz kwie 02, 2006 10:47 pm
autor: the_foe
Cotter Ty tak serio? :-D

wystarczy:
[php]<?php
$number=4.3;
$number=number_format($number,2,",","");
echo $number;
?>[/php]