php - Hiding the decimal if .0 and showing zero if an integer -
i have two, basic number questions.
first, using decimal data type on mysql show data speed or height set 1 decimal place decimal(4,1)
problem numbers no dp still showing .0 - '309.0' want '309'. need change hide '.0'?
second have integer data type showing fixed numbers. many of numbers 0 0 these getting treated null , not displaying. how force 0's display? (i can't make table changes because other columns have zero's null values. 1 column needs zeros display).
for both of these problems php being used display results.
edit: code i'm using display results. top 1 needs not show .0 bottom 1 needs show zero.
length:</b> %sft' . php_eol, $row2['length']) inversions:</b> %s' . php_eol, $row2['inversions'])
i believe sneaky trick if add 0 end of number, removes .0000 etc.
example:
$number = 150.00 $number = $number + 0; //should echo 150 $other_number = 150.500; $other_number += 0; //should echo 150.5
as other, can concatenate zeros since no calculations seem needed
Comments
Post a Comment