-
-
Save Burick/ba934a812ec0a09e185886b43125bc62 to your computer and use it in GitHub Desktop.
MODX output modifier to format number using php number_format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (empty($input) || !is_numeric($input)) return $input; | |
$opts = array_filter(array_map('trim', explode(',', $options))); | |
$args = array(); | |
$args['decimals'] = (isset($opts[0])) ? intval($opts[0]) : 2; | |
$args['dec_point'] = (isset($opts[1])) ? (string) $opts[1] : '.'; | |
$args['thousands_sep'] = (isset($opts[2])) ? (string) $opts[2] : ','; | |
return number_format(floatval($input), $args['decimals'], $args['dec_point'], $args['thousands_sep']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment