Format Number: Returns the supplied number with commas and a decimal point. Fixed for Danish Kroner format.
<?php | |
/** | |
* Format Number | |
* | |
* Returns the supplied number with commas and a decimal point. | |
* Fixed for Danish Kroner format | |
* | |
* @access public | |
* @return float | |
*/ | |
public function formatNumber($n = null) | |
{ | |
if (!$n) return; | |
// remove anything that isn't a number or decimal point. | |
$n = trim(preg_replace('/([^0-9\.])/i', '', $n)); | |
return number_format($n, 2, ',', '.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment