Re: [SMARTY] (Fwd) Re: [SMARTY] accesing asosiative arrays

From: Date: Mon, 08 Jul 2002 01:01:32 +0000
Subject: Re: [SMARTY] (Fwd) Re: [SMARTY] accesing asosiative arrays
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5215@lists.php.net to get a copy of this message
So you're saying if someone does this: $smarty->assign('foo.bar', 'blah'); Smarty would automatically assign the value "blah" to the variable "foo_bar" with no error. Would this be a desired behavior? Thoughts? Monte Ferdinand Beyer wrote:
On 7 Jul 2002 at 1:27, Pupeno wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 How do I access an asosiative array which has a point in the index
(name), for
example: $keys['users.id'] is it posible ? - -- Pupeno: pupeno@pupeno.com http://www.pupeno.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9J9ErLr8z5XzmSDQRAvmBAKC//sNJ815yWjnRLPj8++lSR+ rcMgCgkC/7
NaTd0QMLIo8MpbyPcABOBoE= =DYv9 -----END PGP SIGNATURE-----
Well, you can't. Try to first convert the variables to a valid format, eg. replacing dots (and other characters that are not allowed) with underscores: $smarty->assign('user_id', $myarray['user.id']); or $valid_smarty = array(); foreach ($myarray as $key => $value) { $key = preg_replace('/\\W/', '_', $key); $valid_smarty[$key] = $value; } $smarty->assign($valid_smarty); Perhaps Smarty could do so automatically, Monte? Like PHP automatically converts the graphic.x and graphic.y variables from image submit buttons (<input type="image" name="graphic" />) to $graphic_x and $graphic_y.


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