Sorrow Diary, 2004-12-12, memorized strings into trees

xiaoxiao2021-03-06  46

Beijing Time: 2004-12-12 From about 10:00 to 2004-12-12 11:37 Solved, how to put $ DIRS = Array, "C: / Apache", "C: / Apache / Apache2", "C: / apache / apache2 / bin", "c: / apache / apache2 / bin / iconv", "c: / apache / apache2 / cgi-bin", "c: / apache / apache2 / conf" "C : / Apache / Apache2 / Error "," C: / Apache / Apache2 / Error / Include "," C: / Downloads "," D: "," D: / JBuilder9 "," D: / jbuilder9 / bin ", "D: / JBuilder9 / DOC", "D: / Program", "D: / Program / CRM_TRADE", "D: / Program / Statement Builder"; resolve into a tree structure: finally solved:

* C: ** apache *** apache2 **** bin ***** iconv **** CGI-bin **** conflude ** Downloads * D: ** jbuilder9 *** bin *** DOC ** program *** CRM_TRADE *** statement generator

The parsing problem is flexible, (2004-12-9 Thursday to Plus 2004-12-12 Friday) CAUSE: Always use recursive solution. Thinking is unclear, I am eager to ask for a FTP information tour project.

source:

$ DIRS = Array ("C:", "C: / Apache", "C: / Apache / Apache2", "C: / Apache / Apache2 / Bin", "C: / Apache / Apache2 / Bin / ICONV",

"C: / Apache / Apache2 / CGI-BIN", "C: / Apache / Apache2 / Conf", "C: / Apache / Apache2 / Error", "C: / Apache / Apache2 / Error / Include",

"C: / Downloads", "D:", "D: / JBuilder9", "D: / JBuilder9 / Bin", "D: / JBuilder9 / DOC", "D: / Program",

"D: / Program / CRM_TRADE", "D: / Program / Statement Builder");

// Build directory tree Function CreateTree ($ Directory) {$ PARENT = ""; $ level = 1; $ i = 0; $ n = count ($ Directory); $ cc = 0; $ pre = 0; echo "< Table border = 1> "; for ($ I = 0; $ i <$ n; $ i ) {$ s = evtern (" / ", $ DIRECTORY [$ I]); // Print_R ($ S); $ Cc = count ($ s); if ($ CC> $ pre) {$ level = $ cc;} else {IF ($ CC <$ pre) {$ level = $ cc;}} echo ""; For ($ k = 0; $ k * ";} echo "". $ s [$ level-1]. " / TD> "; $ pre = $ cc; echo" ";} echo" ";

CreateTree ($ DIRS);

转载请注明原文地址:https://www.9cbs.com/read-81688.html

New Post(0)