function search(&$node, &$forest, $id)
{
$node = null;
$len = count($forest);
for ($i=0; $i<$len; PP$i)
{
if ($forest[$i]["id"] == $id)
{
$node = &$forest[$i]; //"&"
return;
}
search($node, $forest[$i]["children"], $id);
if ($node) { return; }
}
}
$forest = array(
array(
"id" => 1,
"pid" => 0,
"children" => array(
array(
"id" => 11,
"pid" => 1,
"children" => array(),
),
),
),
array(
"id" => 2,
"pid" => 0,
"children" => array(),
),
);
search($node, $forest, 11);
echo json_encode($node);