Using str_replace to make BB Code
By Tyler Hopfner
http://www.phphat.net
This is a pretty simple one, you just make a couple arrays with the stuff that you want to be your BB Code, then one that will be the replacements of the BB Code, like this:
<?php
You get the point of that, you can add different tags and replacements if you want, the above is just a small example.
Now all you need to do is use the PHP str_replace() function to make the replacement:
$text="www.tylerhopfner.com";
$bb=array(","" target="_blank">","");
$re=array("<a href="","">link</a>");
?>
<?php
Thats all there is to making your own BB Code.
$text="www.tylerhopfner.com";
$bb=array(","" target="_blank">","");
$re=array("<a href="","">link</a>");
$final=str_replace($bb,$re,$text); // will output <a href="www.tylerhopfner.com">link</a>
?>
Tyler Hopfner
http://www.phphat.net
Tyler is a fourteen year old guy in grade 9. He have been programming and designing for 2 years now. He is very good at PHP & MySQL, and Photoshop.