2017 © Pedro Peláez
 

library php-dot-get

Array dot notation access

image

mkomorowski/php-dot-get

Array dot notation access

  • Wednesday, December 9, 2015
  • by mKomorowski
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

php-dot-get

Array dot notation access, (*1)

Installation

The package can be installed via Composer by adding to the composer.json require block., (*2)

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

Then update application packages by running the command:, (*3)

php composer.phar install

Usage

$dot = new mKomorowski\Notation\Dot;

Get value from array, (*4)

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

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

Tell if the value isset in array, (*5)

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

Set default value returned if given key is not found in array, (*6)

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

$dot->setDefault('undefined');

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

Compare requested value with given one, (*7)

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

The Versions

09/12 2015

dev-master

9999999-dev https://github.com/mKomorowski/php-dot-get

Array dot notation access

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Michal Komorowski

dot php array access notation get