Moh
17-09-2008, 02:36 PM
Well, this is reverse BBCode :P
For my reverse BBCode code, I have the following:
function reversebb($string)
{
$bbcode = array('\\1',
'\\1',
'\\1',
'\\2',
':heart:',
':diamond:',
':club:',
':spade:',
':tm:',
'(l)',
'\\1',);
$replace = array("'<b>(.*?)</b>'",
"'<strike>(.*?)</strike>'",
"'<u>(.*?)</u>'",
"'<font color=\"(.*?)\">(.*?)</font>'",
"'♥'",
"'♦'",
"'♣'",
"'♠'",
"'™'",
"'<img src=\"images/(l).gif\">'",
"'<i>(.*?)</i>'",);
$string = preg_replace($replace, $bbcode, $string);
$string = str_replace("\n", "", $string);
$string = str_replace("<br />\n", "\n", $string);
$string = str_replace("<br />", "", $string);
return $string;
}
But, If $string is "<img src="images/(l).gif">", it dosn't display "(l)", it just displays "<img src="images/(l).gif">".
Can anyone see whats wrong?
For my reverse BBCode code, I have the following:
function reversebb($string)
{
$bbcode = array('\\1',
'\\1',
'\\1',
'\\2',
':heart:',
':diamond:',
':club:',
':spade:',
':tm:',
'(l)',
'\\1',);
$replace = array("'<b>(.*?)</b>'",
"'<strike>(.*?)</strike>'",
"'<u>(.*?)</u>'",
"'<font color=\"(.*?)\">(.*?)</font>'",
"'♥'",
"'♦'",
"'♣'",
"'♠'",
"'™'",
"'<img src=\"images/(l).gif\">'",
"'<i>(.*?)</i>'",);
$string = preg_replace($replace, $bbcode, $string);
$string = str_replace("\n", "", $string);
$string = str_replace("<br />\n", "\n", $string);
$string = str_replace("<br />", "", $string);
return $string;
}
But, If $string is "<img src="images/(l).gif">", it dosn't display "(l)", it just displays "<img src="images/(l).gif">".
Can anyone see whats wrong?