multidimensional array access within foreach loop

From: Date: Sun, 15 Sep 2002 14:19:02 +0000
Subject: multidimensional array access within foreach loop
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5968@lists.php.net to get a copy of this message
Howdy, If I'm in the middle of looping through a foreach block in a template, how do I access a different array based on one of the current loop's values? ie, if this is the loop, with $foo and $blah being two multidimensional arrays it has access to: $foo = array ( id => array ( pid => x , something => y , else => z ) ); $blah = array ( pid => array ( username => a , password => b ) ); { foreach from=$foo name=bar } { $blah[ $bar.pid ].username } {* that's what I'd like to do, anyway *} { /foreach } This doesn't work, nor does any variation I could reasonably expect to work. I can workaround this problem with the SQL querys, but it would make the querys more than mildly inefficient (There's a lot of this sort of referencing going on). As an aside, while attempting to use a section block as a solution, I noticed an apparent loss of ordering in whatever array used... and again couldn't find an answer or reason for this behavior. Strikes me as very odd for this to be expected, so I assume I'm missing something here... markguy

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