preg_replace function
Posted: Fri Sep 19, 2008 4:31 am
Good day,
I'm doing a simple text validator function that replaces a couple of characters. I wanted to add a function that replaces links and emails with <a href="">.
In my text in order to create a link the user types: linkto:mypage.php<description> or mailto:bla@bla.com<mr bla>
I'm not sure how to go about this though:
Is there a way to get my bolded code where bla and bla2 is?
I'm doing a simple text validator function that replaces a couple of characters. I wanted to add a function that replaces links and emails with <a href="">.
In my text in order to create a link the user types: linkto:mypage.php<description> or mailto:bla@bla.com<mr bla>
I'm not sure how to go about this though:
Code: Select all
//patterns to replace
$patterns = array("/Å/", "/å/", "/Ä/", "/ä/", "/Ö/", "/ö/", "/linkto:[b][a-zA-Z0-9._-][/b]+<[b][a-zA-Z0-9._-\s][/b]+>/");
//replacements
$replacements = array("Å", "å", "Ä", "ä", "Ö", "ö", "<a href=\"[b]bla[/b]\">[b]bla2[/b]</a>");