Re: ArrayPath
| From: | Ingwie Phoenix | Date: | Tue, 07 Oct 2014 17:30:11 +0000 |
| Subject: | Re: ArrayPath | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77812@lists.php.net to get a copy of this message | ||
Am 07.10.2014 um 18:05 schrieb Mathias Grimm <mathiasgrimm@gmail.com>:
> Hi,
> I would like to suggest something for php like a class I am using
>
> https://github.com/mathiasgrimm/arraypath
>
> The reason is to access arrays like this:
>
> $idx3 = ArrayPath::get('idx1/idx2/idx3', $_POST, 'myDefaultValue');
>
>
> Regards,
> Mathias
Oh my god. This is seriously one enhancement that I haven’t seen before. If a function like this
makes it into PHP, we can speak of one very unique enhanement here. I like the example of a later
email, as in
$_POST::get(…)
Extending the capabilities of arrays and giving them something like above, would be nice. But I can
see where the syntax would clash: $_POST would be expected to be an object with a __toString()
method, :: refferences to a static method…
But maybe, some smart head can figure something out. It would, at least, be an interesting
functionality.
By the way, I would suggest swapping the path and array argument. As in, „Get from $array the path
‚…‘“. Just a suggestion.