Php 如何以简单的方式像jquery中的数字格式一样格式化?

Php 如何以简单的方式像jquery中的数字格式一样格式化?,php,jquery,ajax,Php,Jquery,Ajax,我想用php替换ajax中hrg1+id上的内容,如下所示: <p id="hrg1<?php echo $id; ?>">Rp.<?php echo number_format($price,0,",",".") ?></p> $("#hrg1"+id).html("Rp."+price); 如何以简单的方式像jquery中的数字格式一样格式化 Rp.<?php echo number_format($price,0,",",".")

我想用php替换ajax中hrg1+id上的内容,如下所示:

<p id="hrg1<?php echo $id; ?>">Rp.<?php echo number_format($price,0,",",".") ?></p>
$("#hrg1"+id).html("Rp."+price);
如何以简单的方式像jquery中的数字格式一样格式化

Rp.<?php echo number_format($price,0,",",".") ?>
Rp。

感谢您的帮助

这里是我的参考资料:

function akoma(nStr){
nStr += '';
x = nStr.split(',');
x1 = x[0];
x2 = x.length > 1 ? ',' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + '.' + '$2');
}
return x1 + x2;
}

alert(akoma(price));
$("#price"+id).html(akoma(price(0)));