Deprecated: Function eregi_replace() Issue

I understand that ereg() and eregi_replace() have been deprecated and should be replaced with preg_match() and preg_replace(), with the ‘i’ modifier, respectively. When I make these updates I get the following error message:

Warning: preg_match() [function.preg-match]: Unknown modifier ‘{’ in /home/content/76/10971376/html/order_form.php on line 206

Fatal error: Call to undefined function pregi_replace() in /home/content/76/10971376/html/order_form.php on line 225

I know very little about PHP and would appreciate any help you are willing to provide.

You must add your code, string input and wanted output.

Thanks JimL. I’ve added the portion of the code where the deprecated functions appear. I don’t know if this is the information you instructed me to supply. Thanks again.

} elseif (!ereg("[0-9]{5}", $frm[“zip”])) {

	$errors->zip = true;

	$msg .= "<li>Zip code should be a 5 digit number.";

} else {

	$temp = eregi_replace("[^0-9]", "", $frm["card_no"]);

	if (!ereg("[0-9]{16,24}", $temp)) {

		$errors->card_no = true;

		$msg .= "<li>This credit card # is invalid.";

} else {

	if (!ereg("[0-9]{4}", $frm["expiration_y"])) {

		$errors->expiration_date = true;

		$msg .= "<li>Credit card expiration year should be a 4 digit number.";

[php]ereg("[0-9]{5}", $frm[“zip”])[/php]

this should now be written as:
[php]preg_match(’/^[0-9]{5}$/’, $frm[“zip”])[/php]

I’ve updated the ereg() function but the eregi_replace() function as shown in my previous post still produces the following message:
Deprecated: Function eregi_replace() is deprecated in /home/content/76/10971376/html/order_form.php on line 225

This code appears as $temp = eregi_replace("[^0-9]", “”, $frm[“card_no”]); in my prior post.

If you can help to resolve this issue I’d appreciate it.

It’s practically the same fix, have you tried fixing it yourself?

I’ve tried several combinations similar to the fix you sent for the ereg() function. Obviously, there is something I’m not doing right but, again, I’m not really that familiar with PHP.

You don’t have to be, you will probably never be familiar with all the thousands of methods available. When accepting that you will learn how to search to find your answer. Figuring this out would’ve is two simple google searches away.

php eregi_replace  preg
php preg_replace all numbers
Sponsor our Newsletter | Privacy Policy | Terms of Service