Coolcrab
Coolcrab

Reputation: 2723

eregi_replace depricated how to replace correctly?

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);

Upvotes: 0

Views: 43

Answers (2)

Coolcrab
Coolcrab

Reputation: 2723

Apparently this works:

$text = preg_replace("#\[img\](.+?)\[/img\]#is", "", $text);

Upvotes: 0

Satish Sharma
Satish Sharma

Reputation: 9635

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

Upvotes: 0

Related Questions