简体   繁体   English

用PHP更改数字格式

[英]changing number format with php

I have numbers like these... 我有这样的数字...

1.235,45
100,00
5,5678
25.321,10

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM