[PHP] Getallen afronden

Gestart doorJosnl17 reacties60 weergaven

18 berichten · pagina 1 van 2

Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo allemaal!

Ik heb een simpel rekenscriptje gemaakt, alleen wil ik dat er maar 2 cijfers achter de komma komen. Dus bijvoorbeeld €10.28.

Ik weet alleen niet hoe ik dat moet doen.
Hier is een gedeelte uit mijn script:

$ex_btw = $_POST["ex_btw"];
$totaal = ($ex_btw / 100 * 119);
$btw = ($totaal - $ex_btw);


echo "Het bedrag inclusief btw  = &euro;$totaal<br /><br />";

echo "U betaalt dus &euro;$btw aan btw.";
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
round($string, 2);shiny
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
round($getal, 2)

Erik was eerder sadley
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik was eerdur. biggrin
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
15 sec. sadley
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja, dat van round wist ik wel, alleen ik weet niet waar ik het moet plaatsen...bloosToch bedankt voor jullie antwoord alvast! yummie
En weten jullie ook hoe het komt dat als ik op F5 druk dat er dan een venster komt over het opnieuw verzenden van gegevens?
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Omdat je een formulier waarschijnlijk post
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$ex_btw[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"ex_btw"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ex_btw[/COLOR] / [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]119[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$btw[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$ex_btw[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Het bedrag inclusief btw  = &euro;$totaal<br /><br />"[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"U betaalt dus &euro;$btw aan btw."[/COLOR][COLOR= #007700];[/COLOR]
?>

shiny
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja, dat klopt, maar is er geen manier om dat weg te halen? emo
PS: Ook antwoord op vraag 1? bloos
EDIT: Thanks Luuk!
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Graag gedaan biggrin
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
IEW IEW IEW, Vars buiten de quotaties pleaseeeee

Zo dus:
Luukvdo schreef:
[COLOR= #0000BB]<?php
$ex_btw[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"ex_btw"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ex_btw[/COLOR] / [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]119[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$btw[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$ex_btw[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Het bedrag inclusief btw  = &euro;"[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"<br /><br />"[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"U betaalt dus &euro;"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$btw[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" aan btw."[/COLOR][COLOR= #007700];[/COLOR]
?>
shiny
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@Rik:
[COLOR= #0000BB]<?php
$ex_btw[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"ex_btw"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ex_btw[/COLOR] / [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]119[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$btw[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$ex_btw[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Het bedrag inclusief btw  = &euro;"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"<br /><br />"[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"U betaalt dus &euro;"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$btw[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" aan btw."[/COLOR][COLOR= #007700];[/COLOR]
?>


Zo dan
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
@rik en luuk dat zei ik ook al tegen hem op msnschater
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@Nielsie,

Nee, jij wist het niet zei je...yummie
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$ex_btw[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"ex_btw"[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ex_btw[/COLOR] / [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]119[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000].[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$btw[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$ex_btw[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000].[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Het bedrag inclusief btw  = &euro;"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$totaal[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"<br /><br />"[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"U betaalt dus &euro;"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$btw[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" aan btw."[/COLOR][COLOR= #007700];[/COLOR]
?>


Number_format is leuker, want dan komt er ook een punt op de duizendbiggrin
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren