Git Product home page Git Product logo

dotarray's Introduction

DotArray

Handle data-arrays and key/value pairs in a fluent way by enabling dot-notation.

Installation

Available through PHP composer

composer require rasmuscnielsen/dotarray

Examples

Instantiate DotArray on a source

$source = array();
$dotArray = DotArray::tap($source);

Now start interacting with your source through DotArray

$cars = $dotArray->open('garage.cars');

$cars->put('mercedes', [
  'model' => 'S-class', 
  'origin' => 'Germany',
  'wheelsize' => '22 inches'
]);
$cars->add('mercedes', [
    'color' => 'blue'
]);

// you could even...
$dotArray->put('garage.cars.mercedes.color', 'blueish');

// or to delete
$cars->open('mercedes')->delete('origin');

Finally you can read out the values in a variety of ways

echo $dotArray->get('garage.cars.mercedes.model'); // S-class
echo $dotArray->get('garage.cars.merecedes.origin'); // NULL
echo $dotArray->get('garage.cars.mercedes.maxspeed', '250km/t'); // 250km/t

// or search out your object
$mercedes = $dotArray->open('garage.cars.mercedes');
echo $dotArray->wheelsize; // 22-inches

// of course you have the whole thing in your souce 
print_r($source); 

// [
//	'garage' => [
//    	'cars' => [
//        	'merecedes' => [
//				'model' => 'S-class',
//				etc...
//]

dotarray's People

Contributors

rasmuscnielsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.