Skip to content

mKomorowski/php-dot-get

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-dot-get

Array dot notation access

##Installation

The package can be installed via Composer by adding to the composer.json require block.

{
    "require": {
        "mkomorowski/php-dot-get": "dev-master"
    }
}

Then update application packages by running the command:

php composer.phar install

##Usage

$dot = new mKomorowski\Notation\Dot;

Get value from array

$array = array(
    'name' => 'Name',
    'firstname' => 'FirstName',
    'address' => array(
        'street' => '',
        'city' => 'Leeds'
    )
);

$dot->get($array, 'address.city'); // 'Leeds'

Tell if the value isset in array

$dot->exists($array, 'address.city'); // true

Set default value returned if given key is not found in array

$dot->get($array, 'address.country') // null

$dot->setDefault('undefined');

$dot->get($array, 'address.country') // 'undefined'

Compare requested value with given one

$dot->assert($array, 'name', 'Name') // true

About

Array dot notation access

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages