---
title: "php怎样把类似价格“20.00元”里的.00替换掉"
author: "tw5566"
date: "2014-01-07T16:33:18Z"
tags: []
categories: ["编程语言"]
slug: "php-20-00-00"
draft: false
lastmod: "2014-01-07T16:33:18Z"
id: 2000425
url: "https://tw5566.iteye.com/blog/2000425"
---

```
$price = "20.00";
$price = preg_replace('/\.0+$/', '', $price);
echo $price."\n"; //结果： 20

$price = "20.60";
$price = preg_replace('/\.0+$/', '', $price);
echo $price."\n";  //结果： 20.60
```