Skip to content

Stingray - Access array elements via dot notation

License

Notifications You must be signed in to change notification settings

burn2delete/Stingray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stingray

Stingray - Access array elements via dot notation

Installing via Composer

Add Stingray to your project:

$>  composer.phar require projectmeta/stingray *

or directly to composer.json:

{
    "require": {
        "projectmeta/stingray": "*"
    }
}

Then update your dependencies:

$>  composer.phar update

Example Usage

To get any node from an array:

<?php

//Some file needing access to array nodes

use projectmeta\Stingray\Stingray;

$stingray = new Stingray();

$someArray = array(
    'node_lvl1' => array(
        'node_lvl2' = array(
            'node_lvl3a' => true,
            'node_lvl3b' => false,
            'node_lvl3c' => array()
            )
        )
    )
);

$nodeAlias = 'node_lvl1.node_lvl2.node_lvl3a';

$newValue = false;

// return true
$stingray->get($someArray, $nodeAlias);

// change true to false
$stingray->set($someArray, $nodeAlias, $newValue);

About

Stingray - Access array elements via dot notation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages