c_pattle Posted June 11, 2010 Share Posted June 11, 2010 Hey. I have a variable that stores the overall total of a shopping cart so for example it's currently 22.50. Is there anyway I can split this variable as I want a seperate one for pounds and a seperate one for pence? Thanks Link to comment https://forums.phpfreaks.com/topic/204471-splitting-a-variable/ Share on other sites More sharing options...
JasonLewis Posted June 11, 2010 Share Posted June 11, 2010 Like explode list($pounds, $pence) = explode(".", $cost); Link to comment https://forums.phpfreaks.com/topic/204471-splitting-a-variable/#findComment-1070725 Share on other sites More sharing options...
c_pattle Posted June 11, 2010 Author Share Posted June 11, 2010 Thanks, also is there a way you can make a variable display to a certain number of decimal places because at the moment £15.50 only displays as 15.5? Link to comment https://forums.phpfreaks.com/topic/204471-splitting-a-variable/#findComment-1070736 Share on other sites More sharing options...
JasonLewis Posted June 11, 2010 Share Posted June 11, 2010 You can bet your bottom dollar there is. number_format You should probably try Googling first, I'm fairly sure it'd turn up. Link to comment https://forums.phpfreaks.com/topic/204471-splitting-a-variable/#findComment-1070776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.