Number Format

4 Years ago(Updated in 4 Years ago) PHP(Functions) 0

Format a number with grouped thousands(please visit number_format in php):

function numberformat($str, $sep=',') {
    $result = '';
    $str = $str.'';
    $c = 0;
    $num = strlen($str);
    for($i=$num-1; $i>=0; $i--) {
        if($c==3) { 
            $result = $sep.$result;
            $result = $str[$i].$result;
            $c = 0;
        } else {
            $result = $str[$i].$result;
  return $result;
//OUT = 1,333,555
echo numberformat(1333555);


No tag here.

Recommended pages

Get all subsets of array...

If you have a list of items (for example)......

File size calculator...

File size calculator function return file size format into kb, mb or gb. function file_size($size, $out = 'kb', $precision = 2) { switch ($out) { case 'kb': return round($...

Gregorian to Persian Date Convertor...

Gregorian to Persian Date Convertor....

URL Checker...

This function check if an url is valid or not. function is_valid_url($url) { return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); }...


No comment here.
captcha image reload