【发布时间】:2023-03-28 09:18:02
【问题描述】:
我有一个包含如下字符串的数组:
$items = array(
"Receive 10010 from John",
"Send 1503000 to Jane",
"Receive 589 from Andy",
"Send 3454 to Mary"
);
我想重新格式化这个数组中的数字,让它变成这样:
$items = array(
"Receive 10.010 from John",
"Send 1.503.000 to Jane",
"Receive 589 from Andy",
"Send 3.454 to Mary"
);
如果我使用number_format 函数,它看起来像这样,带有数字变量:
$number = '412223';
number_format($number,0,',','.');
echo $number; //412.223
【问题讨论】:
标签: php arrays regex number-formatting