For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > March 2006 > eval problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author eval problem
Michael M

2006-03-11, 6:59 pm

Hi, I need your help with the EVAL function.

In PHP I have a list of 27 fields, like this:

$advert['act1'] = 'foo';
$advert['act2'] = 'bar';
....
$advert['act26'] = 'doo';
$advert['act27'] = 'da';

I know this smells like it should be an array, but for
particular reasons it is not. So the template looks
like this:
{$advert.act1}<br>
{$advert.act2}<br>
....
{$advert.act26}<br>
{$advert.act27}<br>

Can I replace this with a loop? Something like:
{section name=foo start=1 loop=27}
{eval var="\$advert.act`$smarty.section.foo.index`"}
<br>
{/section}

The code above does not work, by the way. The line
{eval var="\$advert.act`$smarty.section.foo.index`"}
produces:
$advert.act1

If I add braces:
{eval var="{\$advert.act`$smarty.section.foo.index`}"}
it displays:
{\.act1"}

So I must be missing something here.

Thanks,
Mike

________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com