PHP
·
发表于 5年以前
·
阅读量:8293
function toThousands(number) {
var arr = String(number).split('.');
var num = arr[0], result = '';
while (num.length > 3) {
result = ',' + num.slice(-3) + result;
num = num.slice(0, num.length -3);
}
if (num.length > 0) result = num + result;
return arr[1] ? result + '.' + arr[1] : result
}
}