gpt4 book ai didi

用于遍历目录/文件树和输出树作为嵌套 UL 的 PHP 脚本

转载 作者:太空狗 更新时间:2023-10-29 15:24:23 24 4
gpt4 key购买 nike

<分区>

我有目录、子目录和文件(在一些但不是所有目录中)的树。这是整棵树的示例:

/food
/food/drinks
/food/drinks/water.html
/food/drinks/milk.html
/food/drinks/soda.html
/food/entrees
/food/entrees/hot
/food/entrees/hot/hamburger.html
/food/entrees/hot/pizza.html
/food/entrees/cold
/food/entrees/cold/icecream.html
/food/entrees/cold/salad.html
/cosmetics
/cosmetics/perfume
/cosmetics/perfume/chic.html
/cosmetics/perfume/polo.html
/cosmetics/perfume/lust.html
/cosmetics/lipstick
/cosmetics/lipstick/colors
/cosmetics/lipstick/colors/red.html
/cosmetics/lipstick/colors/pink.html
/cosmetics/lipstick/colors/purple.html

好的,从“/”目录中的 php 脚本,我想递归或遍历此目录树并像这样打印树:

<ul>
<li>food</li>
<ul>
<li>drinks</li>
<ul>
<li>water.html</li>
<li>milk.html</li>
<li>soda.html</li>
</ul>
<li>entrees</li>
<ul>
<li>hot</li>
<ul>
<li>hamburger.html</li>
<li>pizza.html</li>
</ul>
<li>cold</li>
<ul>
<li>icecream.html</li>
<li>salad.html</li>
</ul>
</ul>
</ul>
<li>cosmetics</li>
<ul>
<li>perfume</li>
<ul>
<li>chic.html</li>
<li>polo.html</li>
<li>lust.html</li>
</ul>
<li>lipstick</li>
<ul>
<li>colors</li>
<ul>
<li>red.html</li>
<li>pink.html</li>
<li>purple.html</li>
</ul>
</ul>
</ul>
</ul>

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com