Heim > Artikel > Backend-Entwicklung > PHP之目录 php php 目录操作 php mkdir 多级目
目录操作
递归读取目录内容
<code><span><?php </span> showDir(<span>'../../file'</span>); <span><span>function</span><span>showDir</span><span>(<span>$path</span>,<span>$dep</span>=<span>0</span>)</span>{</span><span>$pos</span> = opendir(<span>$path</span>); <span>while</span>(<span>false</span>!==<span>$file</span>=readdir(<span>$pos</span>)){ <span>if</span>(<span>$file</span>==<span>'.'</span>||<span>$file</span>==<span>'..'</span>) <span>continue</span>; <span>echo</span> str_repeat(<span>" "</span>,<span>$dep</span>*<span>4</span>),<span>$file</span>.<span>''</span>; <span>if</span>(is_dir(<span>$path</span>.<span>'/'</span>.<span>$file</span>)){ <span>$func</span> = <span>__FUNCTION__</span>; <span>$func</span>(<span>$path</span>.<span>'/'</span>.<span>$file</span>,<span>$dep</span>+<span>1</span>); } } }</span></code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了PHP之目录,包括了php,目录方面的内容,希望对PHP教程有兴趣的朋友有所帮助。