Open undercloud opened 7 years ago
Thanks for this suggestion!
I think (if I understand you right) that you can easily achieve this behavior in your application with the PropertyAccess - a standalone Symfony component. For example:
$array = new Arrayzy([
'level_0' => [
'level_1' => [
'level_2' => 'some-value',
],
],
]);
$accessor = PropertyAccess::createPropertyAccessor();
$accessor->getValue($array, 'level_0.level_1.level_2')); // return 'some-value'
Does it makes sense for you? I'm not sure we need it out-of-the-box. What do you think? Do you have some good use cases of it?
I think dot.notation
is trend now :smile:
For example https://laravel.com/docs/5.3/helpers#method-array-get used in many places id L5
OK, let's keep it open for some time, maybe other devs will be interested in it too 😉
You can use like this:
$arrayzy = new A(['a' => ['aa' => 'b']]);
$answer = $arrayzy->nested()->get('a.aa'); // b
To check this edit composer.json:
{
"require": {
"bocharsky-bw/arrayzy": "dev-master"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/AndyDune/Arrayzy"
}
]
}
Support
get->('array.get.key')
?