|
Posted by Duncan Hill on 04/07/05 12:29
On Wednesday 06 April 2005 18:05, Brent Baisley typed:
> You want to have sprintf look at the contents of the variable instead
> of the variable itself. Anytime you want to do something like this you
> use the eval() function to evaluate the contents of the variable.
Woot!
$begin_string = 'htmlentities(sprintf($tmp[0],';
foreach ($p_sub_values as $k => $v) {
$mid_string[] = "\$p_sub_values[$k]";
}
$mid_string = join(',', $mid_string);
$end_string = '), ENT_QUOTES);';
// Eval will stick the three strings together and then execute them. Neat
trick, hint from
// brent@landover.com.
eval ("\$r = $begin_string$mid_string$end_string");
Works a treat. Thanks Brent.
--
My mind not only wanders, it sometimes leaves completely.
Navigation:
[Reply to this message]
|