czproject / relnode-php
v1.0.0
2013-07-10 18:28 UTC
Requires (Dev)
- nette/tester: dev-master
This package is auto-updated.
Last update: 2024-12-14 08:00:29 UTC
README
Helper class.
<?php $root = new Cz\RelNode; $root->addChild('sub/sub1/sub2/sub3', 'sub value'); $root->addChild('sub/sub1/sub2/sub3/sub4', 'sub value 2'); $root->addChild('sub/sub1/sub5', 'sub value 3'); /** Structure: $root └── sub └── sub1 ├── sub2 │ └── sub3 (sub value) [first filled, one of the nearest] │ └── sub4 (sub value 2) │ └── sub5 (sub value 3) [one of the nearest] */ $node = $root->getFirstFilled(); echo $node->value; // 'sub value' $nodes = $root->getNearestChildren(); foreach($nodes as $node) { echo $node->value; // Prints: // 'sub value' // 'sub value 3' } $node = $root->getNearestOneFor('sub/sub1/sub2/sub3/my-sub'); // returns NULL or RelNode instance echo $node->value; // 'sub value' $node = $root->getNearestOneFor('sub/sub1/sub2/sub3/sub4'); // returns NULL or RelNode instance echo $node->value; // 'sub value 2'
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/