Skip to content

Instantly share code, notes, and snippets.

@alroniks
Created August 23, 2012 13:47
Show Gist options
  • Save alroniks/3436764 to your computer and use it in GitHub Desktop.
Save alroniks/3436764 to your computer and use it in GitHub Desktop.
Price formatter
$string = '1000000000';
$array = preg_split('/(?<!^)(?!$)/u', $string);
$array = array_chunk(array_reverse($array), 3);
foreach($array as &$a){
$a = implode("", $a);
}
$result = implode(" ", array_reverse($array));
return $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment