fifin04 Posted October 28, 2009 Share Posted October 28, 2009 Hi guys... Actually I chunk out some data from txtfile and one of the data contains amount value but in string format like so.. "000000010000" -->desire result 100.00 "000000002000" -->desire result 20.00 "000000100050" -->desire result 1000.50 so how's the hell I can format the string so the end result will be 100.00 20.00 1000.50 any help are appreciated..TQ Quote Link to comment https://forums.phpfreaks.com/topic/179321-string-to-currency-format/ Share on other sites More sharing options...
Zane Posted October 28, 2009 Share Posted October 28, 2009 how are you outputting it now. in other words. where's your code. Quote Link to comment https://forums.phpfreaks.com/topic/179321-string-to-currency-format/#findComment-946129 Share on other sites More sharing options...
seanlim Posted October 28, 2009 Share Posted October 28, 2009 number_format(((int) $string)/100, 2); Quote Link to comment https://forums.phpfreaks.com/topic/179321-string-to-currency-format/#findComment-946241 Share on other sites More sharing options...
GingerRobot Posted October 28, 2009 Share Posted October 28, 2009 Bit of a bizarre input format, but you could use ltrim with the optional second parameter to remove the 0s from the left side of the string, then divide by 100 and use the number_format function. Quote Link to comment https://forums.phpfreaks.com/topic/179321-string-to-currency-format/#findComment-946270 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.