
-----------------------------------
Amailer
Wed May 11, 2005 9:26 pm

String from DB into a variable
-----------------------------------
Hey...
Long time since Iv posted here... but anyhow.

I have a table which looks like this:
--------------------------------------------
| variable_name   |    variable_value |
--------------------------------------------
PHP_VER           |   phpversion() 
USERNAME          |   $username
--------------------------------------------


Now I want to create a script that takes the variable name from the database and replaces it with its value. Suppose I create a post on my forum and I put {PHP_VER} in my post, I want it to display the phpversion() on my server, how would I go about doing that?

Doing a simple str_replace simply displays the text phpversion() which is not what I want... I want it to 'run the function'...

Any ideas on how I should do this?

Thanks,
Amailer

-----------------------------------
octopi
Wed May 11, 2005 10:43 pm


-----------------------------------
http://ca3.php.net/eval

-----------------------------------
Amailer
Thu May 12, 2005 6:16 am


-----------------------------------
I knew there was some function out there for this!

Thanks

-----------------------------------
jrblast
Fri Dec 16, 2005 10:17 pm


-----------------------------------
Is this how BBcodes work?

-----------------------------------
octopi
Fri Dec 16, 2005 10:39 pm


-----------------------------------
BBcode is just a simple regex search and replace.
I don't have any examples to throw at you, but you can search on google for     regex or pcre and php
