hassank1 Posted February 18, 2009 Share Posted February 18, 2009 I've a field in db with type decimal(6,1) so when I echo I got values like .. 12.0 , 12.6 , 66,3 etc.. is there a way to remove '.' if it's followed by zero -> new "echo" result : 12 , 12.6 , 66,3 Quote Link to comment https://forums.phpfreaks.com/topic/145717-solved-remove-decimal-point-if-zero/ Share on other sites More sharing options...
RichardRotterdam Posted February 18, 2009 Share Posted February 18, 2009 use round edit oh nevermind you dont want to do that. You could do a split on the . if the last one is 0 then use round Quote Link to comment https://forums.phpfreaks.com/topic/145717-solved-remove-decimal-point-if-zero/#findComment-765063 Share on other sites More sharing options...
Mchl Posted February 18, 2009 Share Posted February 18, 2009 It seems, that the value is stored in string. Cast the value to float, and it should remove the point by itself. Quote Link to comment https://forums.phpfreaks.com/topic/145717-solved-remove-decimal-point-if-zero/#findComment-765096 Share on other sites More sharing options...
hassank1 Posted February 18, 2009 Author Share Posted February 18, 2009 it worked ! Quote Link to comment https://forums.phpfreaks.com/topic/145717-solved-remove-decimal-point-if-zero/#findComment-765099 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.