Formatting prices as swiss francs in PHP is actually very easy .. if you know how.
Requires: PHP 5 >= 5.3.0, PECL intl >= 1.0.0
The number formatter handles all pitfalls like rounding to "5 Rappen", fraction, apostrophe's, etc.
$formatter = new NumberFormatter('de_CH', NumberFormatter::DECIMAL );
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS,2);
$formatter->setAttribute(NumberFormatter::ROUNDING_INCREMENT,0.05);
echo $formatter->formatCurrency(123456.759,'CHF')."<br />\n";
// Output: 123'456.75
echo $formatter->formatCurrency(123456,'CHF')."<br />\n";
// Output: 123'456.00
echo $formatter->formatCurrency(123456.97,'CHF')."<br />\n";
// Output: 123'456.95
echo $formatter->formatCurrency(123456.98,'CHF')."<br />\n";
// Output: 123'457.00
echo $formatter->formatCurrency(.2,'CHF')."<br />\n";
// Output: 0.20
-----------------------------------------
German:
Preise als Schweizer Franken zu Formatieren geht in PHP sehr einfach .. wenn man weiss wie.
Die NumberFormatter Klasse kann auf 5 Rappen runden, Hochkomma setzen, etc.
Benötigt wird PHP 5 >= 5.3.0, PECL intl >= 1.0.0.
Beispiel siehe oben.