Skip to content
/ dotty Public

A simple dot notation array accessor class.

Notifications You must be signed in to change notification settings

laverboy/dotty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dotty - Simple dot notation accessor class

"Dotty is a very nice girl, but she doesn't have a lot to say."

A simple class to get a value, or values, from an array, or many arrays, using dot notation.

Build Status

Usage

$array_to_search = [
    'name' => [
        'firstname' => 'Dotty',
        'lastname' => 'BoBotty',
    ],
    'address' => [
        'addressline1' => '12 Github strasse',
        'country' => 'internet' 
    ]
];

Get single value:

$firstname = Dotty::getValue('name.firstname', $array_to_search);
// $firstname = 'Dotty'

Get array of values:

$array_of_values = [
    'First name' => 'name.firstname',
    'Country' => 'address.country'
];

$details = Dotty::getValues($array_of_values, $array_to_search);
// $details = [
//     'First name' => 'Dotty',
//     'Country' => 'internet'
// ]

Get array of values from multiple arrays to search:

$manyDetails = Dotty::getValuesMultiple($array_of_values, [$array_to_search, $array_to_search]);
// $manyDetails = [
//     [
//         'First name' => 'Dotty',
//         'Country' => 'internet'
//     ],
//     [
//         'First name' => 'Dotty',
//         'Country' => 'internet'
//     ]
// ]

About

A simple dot notation array accessor class.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages