I’m using USAePay’s [horrible] PHP library to connect to their gateway, but I’m getting the following error:
Deprecated: Function ereg_replace() is deprecated in …/usaepay.php on line 320
This corresponds to the following line:
$this->amount = ereg_replace("[^[:digit:].]", "", $this->amount);
So, I’d like to switch it out with preg_replace.
Here’s what I’m thinking:
$this->amount = ereg_replace("/[^[\d].]/", "", $this->amount);
Is this equivalent to the one above, or not?
You want to delete any non-digit or non-period character from the string that represents an amount. You can do:
Regex used: