【问题标题】:changing number format with php用php改变数字格式
【发布时间】:2011-09-23 21:18:27
【问题描述】:

我有这样的数字...

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

但我需要以下格式的数字:

1235.45
100
5.5678
25321.1

【问题讨论】:

    标签: php formatting numbers format


    【解决方案1】:
    $number = str_replace('.', '', $number);
    $number = str_replace(',', '.', $number);
    $number = (float)$number;
    

    应该做的伎俩。

    【讨论】:

      【解决方案2】:
      function cnv($str) {
          $str = str_replace(".", "", $str);
          $str = str_replace(",", ".", $str);
          return (float) $str;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-12
        • 1970-01-01
        • 2019-11-04
        • 2016-10-29
        • 2016-01-19
        相关资源
        最近更新 更多