Re: [SMARTY] section and multiple arrays

From: Date: Mon, 15 Nov 2004 09:52:24 +0000
Subject: Re: [SMARTY] section and multiple arrays
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11962@lists.php.net to get a copy of this message
Hi, Woudn't it be better to use the foreach loop for this: {* smarty *} {foreach item=customer from=$contacts} name : {$customer.name}<BR> home : {$customer.home}<BR> cell : {$customer.cell}<BR> e-mail : {$customer.email}<P> {/foreach} Guido. -- TNG Software van den Hummelstraat 34 5175 CM Loon op Zand tel. 06-26912345 mail: info@TNGSoftware.nl web: http://www.tngsoftware.nl Quoting Valerie Delon <valerie17@gmail.com>: > Salut! > I always got error message or even just white browser (without any output > all) when I use section and associative&multiple arrays since most of the > example from Manual about section always loop=integer values. (only one > associative loop=$contacts, not integer but not with PHP code). > > What I was trying to do is : > > {* smarty *} > {section name=customer loop=$contacts} > name : {$contacts[customer].name}<br> > home : {$contacts[customer].home}<br> > cell : {$contacts[customer].cell}<br> > e-mail : {$contacts[customer].email}<p> > {/section} > > ----- > > <?php > include 'config3.inc.php'; > $smarty = new Smarty_try; > > $name = array('John Smith', 'Jack Jones', 'Jane Munson'); > $home = array('555-555-5555', '666-666-6666', > '777-777-7777'); > $cell = array('111-111-1111', '222-222-2222', > '333-333-3333'); > $email = array('john@smith.com', 'jack@jones.com', > 'jane@munson.net'); > > $contacts = array($name, $home, $cell, $email); > // print_r($contacts);die; > > $smarty->assign('contacts', $contacts); > $smarty->display('section3.tpl'); > ?> > > and I got trigger error. > > Correction to this code above would be very welcome . > > > > Valérie Delon > étudiante > > -- > On a besoin d'apprendre beacoup plus > Quelqu'un croit c'est trop > Mais j'crois que ce n'est pas assez > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.

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