如果不是0,请保留逗号后的值

问题描述 投票:0回答:1

我有以下值

100,00
100,12
122,32
120,00
140,00
123,85

如果逗号后的0等于100,00,那么我需要使其像100。但是如果它是123,85,那么逗号后没有0,则需要像123,85这样保持它。

php explode substr
1个回答
0
投票

只需使用preg_replace功能:

$result = preg_replace("/,00$/", "", $input);
© www.soinside.com 2019 - 2024. All rights reserved.