problem with {section} tag not recognizing array

From: Date: Wed, 18 Dec 2002 09:10:04 +0000
Subject: problem with {section} tag not recognizing array
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6864@lists.php.net to get a copy of this message
Hi everyone, I'm having what I'm sure must be a simple problem with {section} tags: What's happening is that the {section} doesn't repeat, as if the array is empty, so I tried setting up a really simple sample, but it still behaves as if the array is empty: from the php file: $test1 = array( 'name' => 'sebastien', 'sex' => 'male'); from the template file: {section name=customer loop=$test1} <tr> <td>{$test1[0]}</td> <td>{$test1[1]}</td> </tr> {/section} I've tried several different arrays, including: $test2 = array( 1 => array ( 'name' => 'sebastien', 'sex' => 'male' ), 2 => array ( 'name' => 'jenny', 'sex' => 'female' ) ); (Does the array need to be multi-dimensional?) What if I simply wanted a way to have the section repeat for a certain (known) number of times, like while( $row = mysql_fetch_array( $something ) )? I tried assigning an array with the same number of values, even an array with one number value, but to no avail. The manual does not supply the "sample array" ($custid) used in all the examples (http://smarty.php.net/manual/en/language.function.section.html), so it made it a little hard for me to figure out what was going on. Maybe that could be added in later for us beginners :). Thanks in advance for any light you could shed on this. -Sebastien

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