master82 Posted December 26, 2006 Share Posted December 26, 2006 I have $value that contains a currency value (such as $2.50),I want to change the £2.50 into 250 (ie remove the £ and . )How would I go about this? Quote Link to comment https://forums.phpfreaks.com/topic/31868-remove-decimal-point/ Share on other sites More sharing options...
mynamesleo Posted December 26, 2006 Share Posted December 26, 2006 [code]str_replace("£", "", $value);[/code]I guess that would work, and do the same for the . Quote Link to comment https://forums.phpfreaks.com/topic/31868-remove-decimal-point/#findComment-147875 Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 round($number, 0); also works Quote Link to comment https://forums.phpfreaks.com/topic/31868-remove-decimal-point/#findComment-147876 Share on other sites More sharing options...
master82 Posted December 26, 2006 Author Share Posted December 26, 2006 thanks ;D Quote Link to comment https://forums.phpfreaks.com/topic/31868-remove-decimal-point/#findComment-147880 Share on other sites More sharing options...
kenrbnsn Posted December 26, 2006 Share Posted December 26, 2006 If you use the str_replace() method, do it in one call:[code]<?php$value = str_replace(array('£','.'),'',$value);?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/31868-remove-decimal-point/#findComment-147891 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.