小编use*_*094的帖子

RecursiveIteratorIterator和RecursiveDirectoryIterator到嵌套的html列表

这是我的PHP脚本:

<?php

$path = $_SERVER['DOCUMENT_ROOT'].'/test';

$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);

foreach($objects as $name => $object){  
    echo  $objects->getDepth() . " " . $object->getFilename() . "<br/>";
    }

?>
Run Code Online (Sandbox Code Playgroud)

这是脚本迭代的目录/文件树.(它位于一个名为$ _SERVER ['DOCUMENT_ROOT']的简单根目录中.'/ test'):

/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
Run Code Online (Sandbox Code Playgroud)

这是脚本输出的内容:

0 food
1 drinks
2 milk.html
2 water.html
2 soda.html
1 info.php
1 entrees
2 hot
3 pizza.html
3 hamburger.html
2 cold
3 ice_cream.html
3 salad.html …
Run Code Online (Sandbox Code Playgroud)

php recursion iterator html-lists

6
推荐指数
1
解决办法
3270
查看次数

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

我有一个目录,子目录和文件树(在一些但不是所有目录中).这是整棵树的一个例​​子:

/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
Run Code Online (Sandbox Code Playgroud)

好的,从'/'目录中的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>
Run Code Online (Sandbox Code Playgroud)

html php arrays directory recursion

5
推荐指数
3
解决办法
2万
查看次数

Excel VBA 和 ADODB:从 VBA 检索插入 SQL Server 的行的自动标识

在 Excel 的 VBA 模块中。使用 ADODB.Connection 和此连接字符串:

"Provider=SQLOLEDB;Data Source=MARS;Initial Catalog=automation;Trusted_connection=yes;"
Run Code Online (Sandbox Code Playgroud)

我想要:

  1. INSERT INTO test (data) VALUES ('Something')
  2. 检索新插入行的自动递增标识 (test.data_id)。

sql-server excel vba ado

3
推荐指数
1
解决办法
5736
查看次数

标签 统计

php ×2

recursion ×2

ado ×1

arrays ×1

directory ×1

excel ×1

html ×1

html-lists ×1

iterator ×1

sql-server ×1

vba ×1