Reply to Re: [PHP] sprintf and arrays.

Your name:

Reply:


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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация