PHP code example of ama-team / tree-access

1. Go to this page and download the library: Download ama-team/tree-access library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ama-team / tree-access example snippets




$object = new stdClass();
$object->values = ['apples' => 'green'];
$root = [$object];

$accessor = AmaTeam\TreeAccess\TreeAccess::createAccessor();

// 'green'
$color = $accessor->read($root, '0.values.apples');
// List of AmaTeam\TreeAccess\API\NodeInterface
$values = $accessor->enumerate($root, '0.values');
// NodeInterface that got updated
$accessor->write($root, '0.values.melon', 'yellow');
// false
$accessor->exists($root, '0.values.watermelon');



$object = new stdClass();
$object->values = ['apples' => 'green'];
$root = [$object];

$accessor = AmaTeam\TreeAccess\TreeAccess::createAccessor();

$activeNode = $accessor->wrap($object);
foreach ($activeNode->enumerate() as $child) {
    $child->getChild('values')->setChild('lemon', 'yellow');
    $child->setChild('processed', true);
}