用空格分开数字

I want to separate numbers with space like this: 1 200,12 500 or 2 000 000 instead 2000000...

function show_price($id) {
    global $currency_a;
    if(get_option("defaultcurrency")) {
        $curr = $currency_a[get_option("defaultcurrency")][2];
    } else {
        $curr = $currency_a[get_post_meta($id, "currency", true)][2];
    }
    $price = get_post_meta($id, "price", true);
    $currpos = get_option("currpos");
    if($currpos == "1" || !$currpos) {
        return $price."".$curr;
    } elseif ($currpos == "2") {
        return $curr."".$price;
    } elseif ($currpos == "3") {
        return $price;
    }
}

PHP has its very own function for that: number_format()

http://php.net/manual/en/function.number-format.php

Just set the $thousands_sep argument to an empty space instead of the default value. Eg:

number_format($number, 0, '.', ' ');