Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Php Any Variable In String.
sparkx
post Jun 24 2007, 10:47 PM
Post #1


Sparkx
Group Icon

Group: [HOSTED]
Posts: 366
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496
myCENTs:44.66



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:
CODE
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
Go to the top of the page
 
+Quote Post
Quatrux
post Jun 24 2007, 11:20 PM
Post #2


the Q
Group Icon

Group: [HOSTED]
Posts: 1,094
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059
myCENTs:70.96



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 wink.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Reset The Server Variable Php_auth_user(9)
  2. Variable From Line Further Then Current Line?(13)
  3. Quickly Create Form Variables(5)
  4. Unexpected Error(2)
  5. Send Php Variable To Javascript(5)
  6. Permanent Variable(7)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 04:14 PM