Jump to content
xisto Community
Sign in to follow this  
sparkx

Php Any Variable In String.

Recommended Posts

OK well I am making a new php program and I am trying to add bbcode to it. Anyway I was going to replace each thing by it self, but that could cause errors. Anyway is there a way to make a variable be anything? Here is an example:

This is the bbcode:[color=00FF00]Hey[/color]In my php:$bbcode = array("[color=".$a."]");$html = array( "<font color='#".$a."'>");$topic_content = str_replace($bbcode, $html, $posted_bbcode);
So I want $a to be any variable but the same variable as used before. Do you get what I am saying? It is a little confusing but basicly what is the best way to make bbcode? It may not even involve the str_replace but this was the easyiest way to explain what I wanted.

Thanks for everyone that helps,
Sparkx

Share this post


Link to post
Share on other sites

It can be done in several ways, but as for your problem, I think you could just use a regular expression, even though I like to avoid them, I never got into regular expressions, just found them or asked for them on IRC channels, you would need to use preg_replace(); read on it on the php manual <_<

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.