$step = 20; foreach ($keys as $k => $v) { if (is_array($v)) { echo "<div style='padding-left: " . $index * $step . "px'>" . $k . "=></div>"; $index++; printkeys($v, $index); $index--; } else { echo "<div style='padding-left: " . $index * $step . "px'>" . $k . "=>" . $v . "</div>"; } } } $class = "Doc\\demo"; $objDoc = new \Doc($class); $methods = $objDoc->getMethods(); $classdocstr = $objDoc->getClassDoc(); //快速格式化 $classdoc = $objDoc->docFormat($classdocstr); //var_dump($classdoc); //格式化的结果 /* array(8) { ["title"]=> string(27) "这个是类的注释标题" ["explain"]=> string(21) "这个是类的说明" ["author"]=> string(21) "这个是类的作者" ["create"]=> string(38) "2015-12-20 这个是类的创建时间" ["change"]=>