开发者

changing number format with php

I have numbers like these...

1.235,45
100,00
5,5678
25.321,10开发者_StackOverflow社区

But I need those numbers in the following format:

1235.45
100
5.5678
25321.1


$number = str_replace('.', '', $number);
$number = str_replace(',', '.', $number);
$number = (float)$number;

Should do the trick.


function cnv($str) {
    $str = str_replace(".", "", $str);
    $str = str_replace(",", ".", $str);
    return (float) $str;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜