Code: Select all
[url][b]website.com[/b][/url]
evaluates to
<a href="<b>website.com</b>"><b>website.com</b></a>Code: Select all
<?php
function translate($str)
{
$pat[0] = "/[\[]n[\]]/i";
$pat[1] = "/[\[]b[\]]/i";
$pat[2] = "/[\[]i[\]]/i";
$pat[3] = "/[\[]u[\]]/i";
$pat[4] = "/[\[][\/]b[\]]/i";
$pat[5] = "/[\[][\/]i[\]]/i";
$pat[6] = "/[\[][\/]u[\]]/i";
$pat[7] = "/[\[]url[=][&]quot[;](.*)[&]quot[;][\]]/i";
$pat[8] = "/[\[]url[\]](.*)[\[][\/]url[\]]/i"; // the problem is the .*... I need it to pull everything BUT phpbb codes. How?
$pat[9] = "/[\[][\/]url[\]]/i";
$rep[0] = "<br />";
$rep[1] = "<b>";
$rep[2] = "<i>";
$rep[3] = "<u>";
$rep[4] = "</b>";
$rep[5] = "</i>";
$rep[6] = "</u>";
$rep[7] = "<a href=\"$1\">";
$rep[8] = "<a href=\"$1\">$1</a>";
$rep[9] = "</a>";
$str = preg_replace($pat, $rep, $str);
return $str;
}incidently, the reason I'm looking for """ instead of an " is because I just changed all potentially dangerous symbols (<, >, ", ', etc) into the html equivilent.