Forum Moderators: coopster
$replace = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<u>$1</u>',
'<a href="' . check_url('$1') . '">$2</a>',
'<a href="' . check_url('$1') . '">' . check_url('$1') . '</a>',
'<img src="' . check_img('$1') . '" />',
); There's the relevant area of the code, can anyone help?
The ones which aren't passed to a function (i.e. <strong>$1</strong>) are working as expected, right?
EDIT: The reason "$1" is being passed to the function is because you have it quoted. Since PHP doesn't allow variables beginning with numbers, it assumes that a $ followed by a number, in quotes, should be taken literally. If you would have passed it to the function without quotes, you would have gotten an "unexpected T_LNUMBER" error.
Even if the variable were a valid one, the quotes would still be unnecessary, since the variable is already a string.
[url=http://foo.com]something here[/url]
why not just replace all instances of "/\[url=javascript:.*\].*\[url\]/" with a "link removed" text or something? That will weed out any bad links.
Following that, you then replace the remaining legitimate links with <a> tags.
Keep in mind that my regex may be bad because I don't know if some characters should be escaped (and I didn't bother looking it up), so you should write your own. Also, that would obviously only removed the javascript links.
You could do a similar thing for img tags.
Have you tried using the e modifier [php.net]?
There's an example in the documentation [php.net].
Andrew