Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Revover a single value from a nested array

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Walther
Smarty n00b


Joined: 21 Oct 2020
Posts: 1

PostPosted: Wed Oct 21, 2020 10:07 am    Post subject: Revover a single value from a nested array Reply with quote

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.Sad

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
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Sun Oct 25, 2020 8:41 pm    Post subject: Reply with quote

This should work:

{$tldpricing2.pricing.com.register[1]}
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Nov 04, 2020 10:08 pm    Post subject: Re: Revover a single value from a nested array Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP