Can't seem to keep away from this thread (believe me, I triedπ) really should doing the work I get paid for atm, but:
<?php
$tagList['image']=Array('start'=>'<img src="','end'=>'">');
$tagList['bold']=Array('start'=>'<b>','end'=>'</b>');
$tagList['italic']=Array('start'=>'<i>','end'=>'</i>');
$tagList['underline']=Array('start'=>'<u>','end'=>'</u>');
$tagList['link']=Array('start'=>'<a href="','end'=>'">\\\\1</a>');
$tagList['email']=Array('start'=>'<a href="mailto:','end'=>'">\\\\1</a>');
$tagList['link=(.*)']=Array('start'=>'<a href="','end'=>'">\\\\2</a>');
$tagList['email=(.*)']=Array('start'=>'<a href="mailto:','end'=>'">\\\\2</a>');
function processCode($text,$tagList)
{
foreach ($tagList as $tagName=>$replace)
{
$tagEnd=preg_replace('/\\W/Ui','',$tagName);
$text=preg_replace("|\\[$tagName\\](.*)\\[/$tagEnd\\]|Ui","$replace[start]\\\\1$replace[end]",$text);
}
return $text;
}
$text="
[bold]Here[/bold] [italic]are[/italic] my [bold][underline]pictures[/underline][/bold]:
[image]mypic.png[/image]
[image]mynextpic.png[/image]
See more at [link]http://www.foo.com[/link]
Email: [email]danny@foo.com[/email]
[email=danny@foo.com]Email Me[/email]
[link=http://www.foo.com]click here[/link]
";
$newText=processCode($text,$tagList);
echo $newText;
?>
A bit of extra hacking (bound to be a much cleaner way of doing it but I don't have time) to get the vB style link and email tags.
Nope, I've never worked for M$, though they are said to treat their employees well - they're at the wrong end of country anyway.