Permalink
Browse files

Fix example class + add example listing children of "subnode"

  • Loading branch information...
1 parent b86fb35 commit 86cce143f1f633d660d6a68caffd35a2b12bf543 @asm89 asm89 committed Oct 28, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 examples/Zookeeper_Example.php
@@ -124,9 +124,9 @@ public function get($path) {
* @return array the subpaths within the given node
*/
public function getChildren($path) {
- if (!preg_match('@/$@', $path)) {
- // if the path does not end in '/', add a trailing slash
- $path .= '/';
+ if (strlen($path) > 1 && preg_match('@/$@', $path)) {
+ // remove trailing /
+ $path = substr($path, 0, -1);
}
return $this->zookeeper->getChildren($path);
}
@@ -139,3 +139,7 @@ public function getChildren($path) {
var_dump($zk->set('/test123', 'abc'));
var_dump($zk->get('/test123'));
var_dump($zk->getChildren('/'));
+
+var_dump($zk->set('/foo/001', 'bar1'));
+var_dump($zk->set('/foo/002', 'bar2'));
+var_dump($zk->getChildren('/foo'));

0 comments on commit 86cce14

Please sign in to comment.