Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 624 Bytes

README.md

File metadata and controls

31 lines (25 loc) · 624 Bytes

Selector

This library allow to retrieve data from an array or a json string using selectors:

Installation

composer require rezouce/selector

Usage

<?php
use Selector\Selector;
use Selector\Parser\ArrayParser;

$data = [
    'users' => [
        'name' => 'Steve',
        'age' => 49,
    ],
    [
        'name' => 'Edward',
        'age' => 34,
    ],
];

$selector = new Selector($data, new ArrayParser);

$selector->get('users.name'); // return ['Steve', 'Edward']
$selector->get('users[1].name'); // return 'Edward'

License

This library is open-sourced software licensed under the MIT license