0

I just discovered that the eregi is deprecated, and that preg replace works differently. How would you translate this?

$text = eregi_replace("\\[img\\]([^\\[]*)\\[/img\\]", "", $text);
po_taka
  • 1,816
  • 17
  • 27
Coolcrab
  • 2,655
  • 9
  • 39
  • 59
  • Start by reading the [list of differences](http://ca.php.net/manual/en/reference.pcre.pattern.posix.php) between the two different syntax rules. And a nice quide [here](http://docstore.mik.ua/orelly/webprog/pcook/ch13_02.htm) – Athafoud Aug 14 '14 at 11:38

2 Answers2

0

you can try this one

$text = preg_replace("/\\[img\\]([^\\[]*)\\[/img\\]/i", "", $text);
  1. encode your pattern between / and /i
  2. use preg_replace instead of eregi_replace
Satish Sharma
  • 9,547
  • 6
  • 29
  • 51
0

Apparently this works:

$text = preg_replace("#\[img\](.+?)\[/img\]#is", "", $text);
Coolcrab
  • 2,655
  • 9
  • 39
  • 59