Re: [RFC] Additional splat operator usage
| From: | Andrea Faulds | Date: | Sun, 23 Nov 2014 23:35:43 +0000 |
| Subject: | Re: [RFC] Additional splat operator usage | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79108@lists.php.net to get a copy of this message | ||
> On 23 Nov 2014, at 23:07, S.A.N <ua.san.alex@gmail.com> wrote:
>
> I always wanted to have an analog XPath to access the array elements.
> Something like:
>
> <?php
>
> $array = ['x' => ['p' => ['a' => ['t' =>
> ['h' => 'value']]]]];
> $xpath = ['x', 'p', 'a', 't', 'h'];
> $value = $array[...$xpath];
>
> var_dump($value); // string(5) "value"
>
> ?>
>
> This is certainly a topic for another RFC, but this functionality will be
> useful in PHP.
That would be quite confusing, we don’t allow $array[‘x’, ‘p’, ‘a’, ’t’, ‘h’]
just now.
--
Andrea Faulds
http://ajf.me/