Skip to content

Instantly share code, notes, and snippets.

@windows98SE
Last active August 29, 2015 13:58
Show Gist options
  • Save windows98SE/10368984 to your computer and use it in GitHub Desktop.
Save windows98SE/10368984 to your computer and use it in GitHub Desktop.
<?php
$number = '12345678';
function format($number, $len=3, $symbol='฿', $thousand=',', $right=true){
$result = implode($thousand, array_reverse(array_map('strrev', str_split(strrev($number), $len))));
return ($right)?$result.$symbol:$symbol.$result;
}
print format($number, '4');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment