"Christmas - the time to fix the computers of your loved ones" « Lord Wyrm

PHP und Javascript: Ausgabe auf 2 nachkommastellen erzwingen

semteX 08.03.2004 - 21:30 3142 4
Posts

semteX

Risen from the banned
Avatar
Registered: Oct 2002
Location: Pre
Posts: 14365
Topic sagt imho beides.

für php hatte ich schonmal ne lösung, habs aber leider offenbar verschustert :(

bei javascript genau das selbe.

wenn z.b. ne zahl 32.1 ist, dann sollte 32.10 ausgegeben werden. oder z.b. bei 32 sollte 32.00 ausgegeben werden

tia

thx

atrox

in fairy dust... I trust!
Avatar
Registered: Sep 2002
Location: HTTP/1.1 404
Posts: 2782

mad-mat

Addicted
Avatar
Registered: Feb 2001
Location: Undercity
Posts: 426
$foo = round (1.95583,2); // $foo == 1.96

MfG, M.

Edit: immer wieder das selbe... wlkikiv he he :rolleyes:
Bearbeitet von mad-mat am 08.03.2004, 22:13

atrox

in fairy dust... I trust!
Avatar
Registered: Sep 2002
Location: HTTP/1.1 404
Posts: 2782
$foo = round (1.50,2); // $foo == 1.5

$foo = number_format(1.500,2); // $foo == 1.50

semteX

Risen from the banned
Avatar
Registered: Oct 2002
Location: Pre
Posts: 14365
k dank euch!
Kontakt | Unser Forum | Über overclockers.at | Impressum | Datenschutz