Welcome Guest, Not a member yet? Register   Sign In
Parser for Multi-dimensional Array with the same key
#1

(This post was last modified: 03-28-2021, 07:18 PM by emmanuel.)

Consider the followings:
PHP Code:
$template 'Hello {name}, your partner is {partner}{name}{/partner}.';
$data = [
    'name' => 'John',
    'partner' => [
        ['name' => 'Mary'],
    ]
];

$parser = \Config\Services::parser();
echo 
$parser->setData($data)->renderString($template); 


It renders the following output:
Quote:Hello John, your partner is John.


Just wondering how do you access partner's name while it has the same key name. I have tried dot notation , but it seems it doesn't support that.
Reply


Messages In This Thread
Parser for Multi-dimensional Array with the same key - by emmanuel - 03-28-2021, 07:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB