1

I am getting the following error when running on PHP 5.3.8

Deprecated: Function eregi_replace() is deprecated in /home/XXXXXX/public_html/admin/modifypoll.php on line 49

This is the line of code, can anyone help please

$question = eregi_replace('</?[a-z][a-z0-9]*[^<>]*>', '', $question );

I am not sure what to change it to. Can anyone help please

Nanne
  • 64,065
  • 16
  • 119
  • 163
Garry
  • 135
  • 2
  • 13
  • possible duplicate of [Alternative for Deprecated PHP Function eregi_replace](http://stackoverflow.com/questions/2084881/alternative-for-deprecated-php-function-eregi-replace) – Steve Buzonas Dec 30 '11 at 20:26

2 Answers2

5

the entire ereg family of functions are deprecated in PHP and will at some point be removed from the language. The replacement is the preg family. For the most part, the change is simple:

preg_replace('/[^<>]>/i', '', $question);
^--           ^      ^^
  1. change ereg to preg
  2. add delimeters (/)
  3. for case insensitive matches (eregi), add the i modifier
Marc B
  • 356,200
  • 43
  • 426
  • 500
1
$question = preg_replace('/<\/?[a-z][a-z0-9]*[^<>]*>/i', '', $question);

By the way, you can simply use $question = strip_tags($question); to achieve the same without any regexes!

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636