bluecubic Posted July 27, 2006 Share Posted July 27, 2006 I'm trying to trim out several characters. It's not trimming out the comma, it is trimming the other characters. Thanks.Here's what I have now:echo trim($orders['order_total'], '< > b $ / \ ","'); Quote Link to comment https://forums.phpfreaks.com/topic/15835-trim-a-comma-along-with-several-other-characters/ Share on other sites More sharing options...
kenrbnsn Posted July 27, 2006 Share Posted July 27, 2006 Why the quotes around the comma?If you just use:[code]<?php echo trim($orders['order_total'], ' <>b$/\,'); ?>[/code]Does it work?Can you post an example of your input and desired output?Ken Quote Link to comment https://forums.phpfreaks.com/topic/15835-trim-a-comma-along-with-several-other-characters/#findComment-64825 Share on other sites More sharing options...
bluecubic Posted July 27, 2006 Author Share Posted July 27, 2006 I tried to encapsulating the comma in quotes to see if that would work... Thanks for the quick reply. That code unfortunately didn't work. I also just tried [code]echo trim($orders['order_total'], ',');[/code] and it didn't filter out the comma...Example:input: [code]<b>$1,000.00</b>[/code]desired output: 1000.00Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/15835-trim-a-comma-along-with-several-other-characters/#findComment-64840 Share on other sites More sharing options...
kenrbnsn Posted July 27, 2006 Share Posted July 27, 2006 The trim() funtion will only remove character from the beginning or end of a string. You want to look at str_replace():[code]<?php$str = '$1,000.00';echo str_replace(array('$',','),'',$str);?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/15835-trim-a-comma-along-with-several-other-characters/#findComment-64841 Share on other sites More sharing options...
bluecubic Posted July 27, 2006 Author Share Posted July 27, 2006 Thanks Ken!Worked great. Quote Link to comment https://forums.phpfreaks.com/topic/15835-trim-a-comma-along-with-several-other-characters/#findComment-64850 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.