开发者

changing number format with php

开发者 https://www.devze.com 2023-04-07 19:32 出处:网络
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:

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

精彩评论

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