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;
}
精彩评论