Re: Simple question?

From: Date: Sun, 28 Apr 2002 09:43:13 +0000
Subject: Re: Simple question?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3912@lists.php.net to get a copy of this message
"Eric Mueller" <eric@themepark.com> schrieb: > Ok, maybe I'm missing something, but what is the right syntax to display > this each item of $ads in Smarty? > > $ads = array( > array('headline' => 'test1', 'body' => 'hello > world1', 'id' => > '4431'), > array('headline' => 'test2', 'body' => 'hello > world2', 'id' => > '243'), > array('headline' => 'test3', 'body' => 'hello > world3', 'id' => > '342') > ); > > $smarty->assign('ads',$ads); > > The PHP code that I'm trying to mimic in Smarty would go something like > this: > > foreach($ads as $v) { > echo "headline is ".$v['headline']; > echo "body is ".$v['body']; > echo "id is ".$v['id']; > } Hi Eric, try this: {section name=ad loop=$ads} headline is: {$ads[ad].headline} body is: {$ads[ad].body} id is: {$ads[ad].id} {/section} Regards, Norbert

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