Re: [SMARTY] question

From: Date: Fri, 04 Apr 2003 00:23:34 +0000
Subject: Re: [SMARTY] question
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9067@lists.php.net to get a copy of this message
heh - i'm glad I'm wrong. but... i'm stumped again. is there a way to refer to the second index by name? like {$logdata->results[0].(first subscript) } would print: date Thanks again!! gabe On Thu, 3 Apr 2003, messju mohr wrote: > On Thu, Apr 03, 2003 at 10:37:54PM +0000, messju mohr wrote: > > On Thu, Apr 03, 2003 at 04:54:07PM -0500, Super Gabey wrote: > > > > > > can you loop through an array if its index is other than numerical? > > > > > > foo.php > > > $logdata->results[0]['date']="date"; > > > $logdata->results[0]['policy']="policy"; > > > $logdata->results[0]['action']="action"; > > > $logdata->results[1]['date']="ag"; > > > $logdata->results[1]['policy']="pol"; > > > $logdata->results[1]['action']="dance"; > > > > > > > > > foo.tpl > > > {section name=logrowloop loop=$logdata->results[0]} > > > {$logdata->results[0][logrowloop]} > > > {/section} > > > > > > > > > > > > It appears as if this won't work - but I'd really like to be wrong :( > > > > you a wrong. :) > > > > you want to do > > {foreach from=$logdata->results.0 key=name item=value} > > $value > > {/foreach} > > > > ({foreach} can loop over arbitrary array, {section} only over indexed > > ones) > > > > of course you dont need "key" in this example, since it isn't use, > > but you have access 'date', 'policy', 'action' ... if you > > need > > > > you could also write "$logdata->results.0.$key" instead of > > "$value", > > but "$value" is simpler, better faster. > > sorry about the horrible speling. i've been a bit in a rush. i hope > it's understandable with a bit of imagination :) > > > HTH > > messju > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.smarty.general (#9067) next »