note 71690 deleted from function.tidy-node-get-nodes by bjori
| From: | bjori@php.net | Date: | Tue, 12 Dec 2006 09:02:54 +0000 |
| Subject: | note 71690 deleted from function.tidy-node-get-nodes by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-120541@lists.php.net to get a copy of this message | ||
Note Submitter: brutuscat at gmail dot com
----
I made a get_nodes implementation for the missing one in the PHP 5.1.2
<?php
function get_nodes($node, $type)
{
function recursive_get_node($node, $type)
{
$ret = array();
if($node->child != null)
{
foreach($node->child as $child)
{
$temp = recursive_get_node($child, $type);
if(is_array($temp))
$ret = array_merge($ret, $temp);
if($child->id == $type)
{
$ret[] = $child;
}
}
return $ret;
}
}
$result = array();
if($node->id == $type)
$result[] = $node;
$result = array_merge($result, recursive_get_node($node, $type));
}
?>