使用php更改数字格式

使用php更改数字格式,php,formatting,numbers,format,Php,Formatting,Numbers,Format,我有这样的数字 1.235,45 100,00 5,5678 25.321,10 但我需要以下格式的数字: 1235.45 100 5.5678 25321.1 我们应该做到这一点 function cnv($str) { $str = str_replace(".", "", $str); $str = str_replace(",", ".", $str); return (float) $str; } function cnv($str) { $str

我有这样的数字

1.235,45
100,00
5,5678
25.321,10
但我需要以下格式的数字:

1235.45
100
5.5678
25321.1
我们应该做到这一点

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