Rocko Jedi Rocko Jedi - 2 years ago 120
PHP Question

eregi_replace deprecated

Possible Duplicate:

Deprecated: Function eregi_replace()

I have an error that reads:

Deprecated: Function ereg_replace() is deprecated in /home/socia125/public_html/wi_class_files/autoMakeLinks.php on line 26

My code is here. Any help is appreciated.


class autoActiveLink {

function makeActiveLink($originalString){

$newString = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a

href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);
return $newString;


Answer Source

Using preg_replace:

$newString = preg_replace("#[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]#","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download