Ninjakreborn Posted December 25, 2007 Share Posted December 25, 2007 How would I change a number formatted like 0.056 into one formatted like 5.6%. basically I need to take any number with a 0.056 type of format over to a 5.6 type of format. Is this possible, if so how, and thanks. Merry Christmas also. Quote Link to comment https://forums.phpfreaks.com/topic/83152-solved-change-decimal-to-percentage/ Share on other sites More sharing options...
kenrbnsn Posted December 25, 2007 Share Posted December 25, 2007 Multiply the number by 100. Ken Quote Link to comment https://forums.phpfreaks.com/topic/83152-solved-change-decimal-to-percentage/#findComment-422934 Share on other sites More sharing options...
helraizer Posted December 25, 2007 Share Posted December 25, 2007 Yeah. 0.056 * 100 = 5.6% 1 * 100 = 100% So, in php $dec = 0.54; //an integer that is 0.54 $percent = $dec * 100; echo $percent."%"; Or similar Sam Quote Link to comment https://forums.phpfreaks.com/topic/83152-solved-change-decimal-to-percentage/#findComment-422944 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.