Re: PHP smarty and subarrays
| From: | Andrey Repin | Date: | Wed, 07 Sep 2022 06:37:21 +0000 |
| Subject: | Re: PHP smarty and subarrays | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-328054@lists.php.net to get a copy of this message | ||
Greetings, gordonisnz@gmail.com.
In reply to Your message dated Monday, September 5, 2022, 10:55:02,
> 1) Does anyone know of a good PHP Smarty forum? There was one, but
> they took it off & went to Reddit - Gone downhill since then (very few
> people transferred)
Most of the active users are moved there. So, feel free to ask your questions.
> or can i ask my smarty questions here? (not many folks may use smarty ??)
> 2) Question:-
> I know how to assign values within a template:
> {if !isset($HIDEMAINMENU)}{assign var="HIDEMAINMENU" value="0"}{/if}
> however, does anyone know the correct way of assigning (or retrieving)
> sub-arrays?
> (PHP)
> $myarray["animals"]["movies"]["settings"]["trees"] = 5;
Very first, you don't need "assign".
> How do I set it to do the same thing with smarty:- the only examples
> i can see, assign NEW arrays (not assigning new keys/values to an
> existing array)
You can go as far as
{$v=[]}
{$v= $v + ["Title" => "x"]}
{$v|print_r:true}
{$v.Title}
> Or
> How to assign a sub-array value to a $temp variable (not an array)
> When I try the obvious things - i get all sorts of errors
Which errors, specifically?
And on a side note, your request is strange.
Why don't you do it at the PHP side? You should not write your business logic
in Smarty.
--
Sincerely Yours, Andrey Repin <anrdaemon@yandex.ru>