illuz1on Posted October 20, 2010 Share Posted October 20, 2010 Hi, Im looking at using a statement like this to remove all text characters from a string. $outgoing = substr_replace($incoming,"",-1); The string is a currency that has a currency symbol in the beginning of the string, like "R500.00" I would like to remove the R, so it is just a numeric value... Please can you help me with any ideas on how to get this going? Been reading so much and its all confused me too badly. Regards, Chris Quote Link to comment Share on other sites More sharing options...
illuz1on Posted October 20, 2010 Author Share Posted October 20, 2010 I have made a bit more progress... <?php $mynewprice = $product_price; function deleteFirstChar( $mynewprice ) { return substr( $mynewprice, 1 ); } $rightprice = deleteFirstChar( $mynewprice ); ?> I was hoping $rightprice would be the stripped value of 550.00 -------------------------- I think im struggling because $product_price returns this: <div class="yagendoo_productPrice"> <span class="yagendoo_productPrice"> R550.00 </span> </div> So I think now, I need to make it strip ALL characters except for numeric chars.. Any ideas? Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 would this help you? $string = '100.000.000 zilion trillion billion euros'; $pattern = '/[^0-9]/i'; $replacement = ''; echo preg_replace($pattern, $replacement, $string); // this will output 100000000 Put your code in code tags btw much easier to read it Quote Link to comment 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.