Ok so I want to add some url's to user input such that they can make full fledged hyperlinks. But I want them to be able to use a simplified code that doesn't get stripped by htmlspecialchars.
It would look like this: [link="someurl"]link text[/link]
here's my code so far
<?php
$mystring="[link=\"someurl\"]link text[/link]";
$myhtml=addbackhtml($mystring);
print ($myhtml);
function addbackhtml($mystring){
$nonhtml_link="/([link=\")(.*)(\"\])/(.*)(\[/link\])/";
$html_link="<a href=\"$2\">$4/a>";
$mystring= preg_replace($nonhtml_link,$html_link,$mystring);
return $mystring;
}
?>
I get : Warning: Unknown modifier '(' in addbackhtml.php on line X
X being the line that contains the preg_replace.
Thanks in advance