-3

I have this warning, Deprecated: Function ereg_replace() is deprecated someone please help me.

ereg_replace:

ereg_replace('([^(folder)])/images/flash', '"/folder/images/flash', $echotemp);

to preg_replace:

Michael A
  • 9,480
  • 22
  • 70
  • 114
user311129
  • 23
  • 3
  • Well, you can start [here](http://php.net/manual/en/function.preg-replace.php), and especially [here](http://www.php.net/manual/en/reference.pcre.pattern.posix.php). – Dan Lugg Dec 27 '11 at 09:04
  • What language is this? Add this info if you want more specific answers, it'll help your question visibility – samy Dec 27 '11 at 09:04
  • What do you think `([^(folder)])` means within a regex? – Toto Dec 27 '11 at 12:37

2 Answers2

0

A deprecated method is a method that will in the future be dropped out of the language you're using. Unless you've got control on the language specifications and roadmap, you don't have much leverage.

You can still use the method, but it can disappear in a future update, and usually support about the method will just recommend switching to the new recommended ways of doing things.

I recommend using the replacement method for ereg_replace.

samy
  • 14,832
  • 2
  • 54
  • 82
0

From: ereg_replace

Note:
As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE.

.

Tip

preg_replace(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg_replace().

Read: PCRE regex syntax


And for your pattern:

When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~).

If the delimiter needs to be matched inside the pattern it must be escaped using a backslash. If the delimiter appears often inside the pattern, it is a good idea to choose another delimiter in order to increase readability. So, your pattern should look like:

([^(folder)])/images/flash
[] that you have use in [^(folder)] is for specifying character-set and not a whole word. Its better to use simple patterns and not complicate a search pattern.

%^/folder/images/flash%
This is more simple. I am using % as delimiter for readability. Not using # because stackoverflow will treat it as a heading :P.

ThinkingMonkey
  • 12,539
  • 13
  • 57
  • 81