Jimbo wrote:


I query and use mysql_fetch_array to get the data into an associative array. I then build a string and output it like this: echo "blah blah ".$row["thecolumn"]." blah blah";


What you need to understand is that the string parsing for variables only happens when the string is actually in your script. When you dynamically create a string (or get it from a DB) it's just a string of characters in memory and is *not* parsed.


To do something like this, you would have to use one of a few things. The first would be to use some kind of search and replace to replace those variables with what you really want.

$text = str_replace('$name', $name, $text);

That's fairly simple and could even be done for multiple variables.

foreach(array('name', 'price') as $varName) {
  //yes, the $$ is correct
  $text = str_replace('$'.$varName, $$varName, $text);
}

You could also use a regular expression if you *really* wanted to, but what's above is easier.

--
paperCrane <Justin Patrin>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to