Rocko Jedi Rocko Jedi - 7 months ago 19
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.

<?php

class autoActiveLink {

function makeActiveLink($originalString){

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

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

}
?>

Answer

Using preg_replace:

$newString = preg_replace("#[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]#","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);