|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Walther Smarty n00b
Joined: 21 Oct 2020 Posts: 1
|
Posted: Wed Oct 21, 2020 10:07 am Post subject: Revover a single value from a nested array |
|
|
Hello.
I need to recover single values from a deeply nested array; the available documentation is quite laconic, I'm a newbie for Smarty, and I did several attempts without success... so here I'm asking for help.
I have an array with following structure (reported by Smarty debug):
Code: | $tldpricing2
Origin: "Smarty object"
Value
Array (3)
result => "success"
currency => Array (6)
id => "1"
code => "USD"
prefix => "$"
suffix => " USD"
format => "1"
rate => "1.00000"
pricing => Array (13)
com => Array (8)
categories => Array (2)
0 => "gTLD"
1 => "Popular"
addons => Array (3)
dns => false
email => false
idprotect => false
group => ""
register => Array (1)
1 => "14.95"
transfer => Array (1)
1 => "14.95"
renew => Array (1)
1 => "14.95"
grace_period => Array (2)
days => 30
price => WHMCS\View\Formatter\Price Object (0)
redemption_period => null
net => Array (8)
categories => Array (2)
0 => "gTLD"
1 => "Popular"
addons => Array (3)
dns => false
email => false
idprotect => false
group => ""
register => Array (1)
1 => "14.95"
transfer => Array (1)
1 => "14.95"
renew => Array (1)
1 => "14.95"
grace_period => Array (2)
days => 30
price => WHMCS\View\Formatter\Price Object (0)
redemption_period => null |
I would need to recover in Smarty the value, i.e. of
$tldpricing2->pricing->com->register->1
What's the right syntax?!?!?!
Thank you for your attention and your help |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sun Oct 25, 2020 8:41 pm Post subject: |
|
|
This should work:
{$tldpricing2.pricing.com.register[1]} |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Nov 04, 2020 10:08 pm Post subject: Re: Revover a single value from a nested array |
|
|
Walther wrote: | the available documentation is quite laconic, I'm a newbie for Smarty |
You have to know PHP to start learning Smarty. The original language is PHP anyway, without knowing it, you can't make the next step. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|