hi all.
i'd like to convert bb-code with the following code:
<?php
$text = "
[i]hallo[/i]
";
function convertSimplicityCode($text) {
$text = preg_replace("/\[([biu])\](.*)\[\/([$1])\]/i","<$1>$2</$1>",$text);
return $text;
}
echo "<textarea>".convertSimplicityCode($text)."</textarea>";
?>
but it does not seem to work with the $1. 🙁
it works using
preg_replace("/\[([biu])\](.*)\[\/([biu])\]/i","<$1>$2</$1>",$text);
but then it will also parse
hello[/i]
as <u>hello</u>
is it not possible to use $1, $2 etc. in the preg_match pattern?
thank you for info. 🙂