(Fwd) Re: [SMARTY] accesing asosiative arrays

From: Date: Sun, 07 Jul 2002 09:56:01 +0000
Subject: (Fwd) Re: [SMARTY] accesing asosiative arrays
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5213@lists.php.net to get a copy of this message
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. -- Ferdinand Beyer <fbeyer@clickhand.de>-- Ferdinand Beyer <fbeyer@clickhand.de>

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