Welcome to Webmaster Resources 101
Webmaster resources, forums, articles & tools.
Our Network:
Using str_replace to make BB Code
[ About This Author :: Request Reprint :: Print Article :: Tell A Friend ]
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:
<font color="green"><?php
$text="<a href="www.tylerhopfner.com" target="_blank">www.tylerhopfner.com</a>";
$bb=array("<a href="","" target="_blank">","</a>");
$re=array("<a href="","">link</a>");
?></font>
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 <i>str_replace()</i> function to make the replacement:
<font color="green"><?php
$text="<a href="www.tylerhopfner.com" target="_blank">www.tylerhopfner.com</a>";
$bb=array("<a href="","" target="_blank">","</a>");
$re=array("<a href="","">link</a>");
$final=str_replace($bb,$re,$text); // will output <a href="www.tylerhopfner.com">link</a>
?></font>
Thats all there is to making your own BB Code.
Discuss this in our Webmaster Forums
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.
| Go To Top | This article has been read 1129 times. |
[ About This Author :: Request Reprint :: Print Article :: Tell A Friend ]
Link Exchange
LinkAdage allows webmasters to make money on their websites buying and selling relevant, high pagerank / high traffic text links.
Best 10 Web Hosting
Leading Web Hosting Industry Directory. Host Search, News and Reviews. Compare the Best Shared Hosting Plans Under $10 a Month. Unix, Windows and Java hosts. Budget, Shared, Reseller and Dedicated providers. Hosts in Canada, Australia and Europe.
Web Hosting
» Web Hosting India
Software
» MAS 90
Link Popularity
» Reciprocal Link Exchange Directory