Computer Science Canada

String from DB into a variable

Author:  Amailer [ Wed May 11, 2005 9:26 pm ]
Post subject:  String from DB into a variable

Hey...
Long time since Iv posted here... but anyhow.

I have a table which looks like this:
code:
--------------------------------------------
| 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

Author:  octopi [ Wed May 11, 2005 10:43 pm ]
Post subject: 

http://ca3.php.net/eval

Author:  Amailer [ Thu May 12, 2005 6:16 am ]
Post subject: 

I knew there was some function out there for this!

Thanks

Author:  jrblast [ Fri Dec 16, 2005 10:17 pm ]
Post subject: 

Is this how BBcodes work?

Author:  octopi [ Fri Dec 16, 2005 10:39 pm ]
Post subject: 

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


: