首页 > 代码库 > PHP递归

PHP递归

   public static function getNode($node_arr = [], $pid = 0)    {        $node_arr = empty($node_arr) ? self::getAll() : $node_arr;        $node = [];        $tem = [];        foreach ($node_arr as $v) {            if ($v[‘pid‘] == $pid) {                $tem = self::getNode($node_arr, $v[‘id‘]);                $tem && $v[‘child‘] = $tem;                $node[] = $v;            }        }        return $node;    }

 

PHP递归