Re: [SMARTY] Associative array access with space in key

From: Date: Fri, 19 Apr 2002 13:24:04 +0000
Subject: Re: [SMARTY] Associative array access with space in key
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3812@lists.php.net to get a copy of this message
On Thu, 18 Apr 2002, Greg Dykema wrote: > Greetings, > > I've been through the manual and the mailing list archives, but I can't > figure out how to make a reference to an associative array element whose > key contains a space. For example, I've got an array with elements like > > $a["Class ID"] = 1234; > > I've tried { $a.Class ID } and { $a."Class ID" } but just get errors. > References without spaces in the key work fine. Unfortunately the data > structure is coming from a database access routine and I have no way of > knowing what characters might be used in the keys. Currently, you cannot use access keys with spaces in them. In the next release of Smarty you can do this workaround: {assign var="mykey" value="Class ID"} {$a.$mykey} > Actually, the actual data structure is a combination of associative > arrays and arrays, so the real references I'm making look like > { $a.foo[0] }. I don't see anything wrong with {$a.foo[0]}. -Andrei "The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" but "That's funny..." -- Isaac Asimov.

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