ivy
02-24-2008, 02:34 PM
Hi there.
I have a database with some figures in it and they are formatted as decimals with one figure after decimal place.
If the figure finishes in .0 I want to remove the .0
If the figure ends in .1 (to .9) then I want to keep it
I used the following:
echo eregi_replace('.0', '', $row['figure']).' cms';
Strange thing that happens is that when the figure in the database is 20.0 I get no figure displayed! I just get "cms". If I change the figure to 21.0 in the database, it displays it perfectly!
I cannot see why this would be!
Any help trulty appreciated!
I have a database with some figures in it and they are formatted as decimals with one figure after decimal place.
If the figure finishes in .0 I want to remove the .0
If the figure ends in .1 (to .9) then I want to keep it
I used the following:
echo eregi_replace('.0', '', $row['figure']).' cms';
Strange thing that happens is that when the figure in the database is 20.0 I get no figure displayed! I just get "cms". If I change the figure to 21.0 in the database, it displays it perfectly!
I cannot see why this would be!
Any help trulty appreciated!