Fw: possible to parse through vars?
| From: | j dot metzger at steptown dot com | Date: | Mon, 18 Aug 2003 15:34:24 +0000 |
| Subject: | Fw: possible to parse through vars? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10087@lists.php.net to get a copy of this message | ||
Hi,
i want to do the following:
1. get all vars starting with a certain pattern
2. extract the names of that vars
3. assign them in a special way...
example:
example.tpl
-----------------
<html>
<body>
<h3>
{$IMAGE_PETER_GIF}
</h3>
<h3>
{$IMAGE_HANS_JPG}
</h3>
</body>
</html>
--> now extract all var-names from template...
$smarty->new Smarty();
foreach ($names as $key){
if (substr($key,0,5)=="IMAGE")
$t_piece=explode("_",$key);
$t_image='<img
src="images/'.$t_piece[1].".$t_piece[2]"."\">";
$smarty->assign($$key,$t_image);
}
$smarty->display(example.tpl);
Any Ideas,
thanx in advance
Jochen