<?php //初始化数组信息 $nodes = array( array('text'=>'root','id'=>'1','node'=>'-100','cls'=>'folder'), array('text'=>'aaa1','id'=>'2','node'=>'1','cls'=>'folder'), array('text'=>'bbb2','id'=>'3','node'=>'1','cls'=>'folder'), array('text'=>'ccc3','id'=>'4','node'=>'1','cls'=>'folder'), array('text'=>'a111','id'=>'5','node'=>'2','cls'=>'file','leaf'=>'true'), array('text'=>'a112','id'=>'6','node'=>'2','cls'=>'file','leaf'=>'true'), array('text'=>'a113','id'=>'7','node'=>'2','cls'=>'file','leaf'=>'true'), array('text'=>'b111','id'=>'8','node'=>'3','cls'=>'file','leaf'=>'true'), array('text'=>'b112','id'=>'9','node'=>'3','cls'=>'file','leaf'=>'true'), array('text'=>'b113','id'=>'10','node'=>'3','cls'=>'file','leaf'=>'true'), array('text'=>'c111','id'=>'11','node'=>'4','cls'=>'file','leaf'=>'true'), array('text'=>'c112','id'=>'12','node'=>'4','cls'=>'file','leaf'=>'true'), array('text'=>'c113','id'=>'13','node'=>'4','cls'=>'file','leaf'=>'true') ); //var_dump($nodes); //定义通过节点ID来获取新节点的函数 function get_node($arr,$id,$back_arr){ for($i=0; $i < count($arr); $i++){ if($id == $arr[$i]['node']){ array_push($back_arr,$arr[$i]); } } return($back_arr); } //初始化返回的数组 $return_node = array(); //获得节点信息 $nid =
POST['node_id']; $ntext =___FCKpd___0
POST['node_text']; echo json_encode(get_node($nodes,$nid,$return_node)); ?>___FCKpd___0