- var_dump: documentation ( source)
- round: documentation ( source)
- setlocale: documentation ( source)
- money_format: documentation ( source)
<?php
// Gegeven: de prijs inclusief btw komt uit de database
$totaal = 49;
// Artikelprijs exclusief btw berekenen:
$prijs_exclusief_btw = round($totaal / 1,21, 2);
// Dus dan is de btw:
$btw = $totaal - $prijs_exclusief_btw;
// Hierna pas de getallen omzetten in strings:
setlocale(LC_MONETARY, 'nl_NL');
$prijs_exclusief_btw = money_format('%.2n', $prijs_exclusief_btw);
$btw = money_format('%.2n', $btw);
$totaal = money_format('%.2n', $totaal);
echo '<pre>';
var_dump($totaal);