Autor Beitrag
Philer
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 79

Win XP Home
D7 Enterprise
BeitragVerfasst: Sa 31.07.04 16:47 
Kennt sich jemand mit PHP aus? Wie runde ich eine kommazahl auf die nächstliegende natürliche zahl? z.B. wenn es 4.2 ist das dann 5 rauskommen...
Mag vielleicht ganz einfach sein. Vllt gibts da eine funktion also round(); rundet nicht so wie ich'S haben will

//EDIT: hab's selbst gelöst:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
<?php
if (($i - round($i)) > 0 ) {
    if (($i - round($i))< 0.5 ) {
        $i = round($i) + 1;
    }
} else
  $i = round($i);
echo $i;
?>

_________________
- Delphi n00b -
-Philer teh thriller-
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Sa 31.07.04 16:48 
Viiieeel einfacher:
ausblenden Quelltext
1:
ceil();					


raziel

_________________
JSXGraph
Philer Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 79

Win XP Home
D7 Enterprise
BeitragVerfasst: Sa 31.07.04 17:10 
*lol* du lachkrämpfe-verursacher.
hättest ja gleichsagen können ..
Ich muss mal die Funktion-referenz auswendig lernen o_O

_________________
- Delphi n00b -
-Philer teh thriller-
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Sa 31.07.04 17:27 
Wieso gleich? Innerhalb von einer Minute Antwort, gleicher gehts ja gar net! ;-)
Falls Du 's noch nicht hast, lad dir das php-Manual:
php.he.net/get/php_m...de.chm/from/a/mirror

raziel

_________________
JSXGraph