我在数字中得到了一个字符串值,就像2345.567一样,我希望在十进制之后只保留一个字符。我不想使用任何数字函数,我只是想删除任何字符后的句点(点)?
发布于 2012-07-28 07:45:18
您可以这样做:
$string = "234567.2345";
if(!is_numeric($string)) {
$output = $string;
}
else{
$output = round($string,1);
}
输出将
234567.2
如果字符串给定为234
output will be 234.o
如果给出的字符串不是数字"asdf“
output will be asdf
https://stackoverflow.com/questions/11699135
复制相似问题