phpdeprecatederegi

eregi_replace() is deprecated


I have just created a simple word filter for users bios when they are updated. This is the code:

 for($i=0;$i < sizeof($badwords);$i++){
  srand((double)microtime()*1000000); 
  $rand_key = (rand()%sizeof($replacements));
  $str = eregi_replace($badwords[$i], $replacements[$rand_key], $str);
 }
 return $str;



}

When I submit the Bio, the text saves however I get this error:

Deprecated: Function eregi_replace() is deprecated in /home/u557520691/public_html/inc/Global.php on line 177

Does anybody know how to fix this issue?


Solution

  • try this

    How to replace ereg?

    or just turn the notice off

    error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
    

    or

    error_reporting(E_ALL ^ E_DEPRECATED);