RE: [SMARTY] (Fwd) Re: [SMARTY] accesing asosiative arrays
| From: | Gary Loescher | Date: | Mon, 08 Jul 2002 05:24:47 +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-5218@lists.php.net to get a copy of this message | ||
To me, this would not be good. It would eat up a few
more cycles on the assignment and the template parsing
side (I'm assuming that a template var of $foo.bar
would then be internally translated into foo_bar;
otherwise, we'd get a deluge of posts :). IMHO, it's
ok to have certain characters be disallowed in var
names.
Gary
>-----Original Message-----
>From: Monte Ohrt [mailto:monte@ispi.net]
>Sent: Sunday, July 07, 2002 8:02 PM
>To: Ferdinand Beyer
>Cc: smarty-general@lists.php.net
>Subject: Re: [SMARTY] (Fwd) Re: [SMARTY] accesing
>asosiative arrays
>
>
>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.
>>
>>
>>
>
>
>
>
>--
>Smarty General Mailing List (http://smarty.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>