1

I am working on one of the ecommerce project in OScommerce and I have to implement google tracking in it, Google doesn't allows product price with currency symbol as a parameter in it's method . but on my payment success page I got product price with the currency symbol. So, is there any way through which we extract numeric value from product price.

Cœur
  • 37,241
  • 25
  • 195
  • 267
sandeepsure
  • 1,113
  • 1
  • 10
  • 17

1 Answers1

2

Try:

$price_no_curr = preg_replace ( '#\D*?(\d+(\.\d+)?)\D*#', '$1', $price); 
Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66
  • An explanation of how it works would make this answer better. This type of answer tends to fosters copy and paste coders. – frederickjh Aug 15 '19 at 12:36