我试图显示产品的价格,当价格是一个整数时,不显示小数点“.00”;但当前结果总是显示十进制值。我在下面提供了我当前的逻辑;
$price_value = "20.00"; //coming from DB as string
if (is_int($price_value)) {
//Display whole number without decimal
$to_print = number_format($price_value,0);
else {
//Show the decimal value
$to_print = number_format($price_value,2);
}
//When I print this value I always get "`20.00`" not "`20`"