473,326 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

TREE command

Hi folks,
I notice both unix and windows have the tree command for viewing a systems
files from the current dir downwards. Is there anyway in PHP which I could
use this command and make a tree with all the directories clickable? So
users could go to them directories?

Or what are others ways for navigation, basically one function I have for
instance is copy, a user selects a file to copy and on the next screen is
presented with a textbox to type wheer to copy in. It would be nice if I
could have something graphically for them to click on and then update the
box. Anyknow know anything on this or resources, anything in PEAR?

Thanks in advance.
Dave
Jul 17 '05 #1
2 1919
On Tue, 21 Dec 2004 22:07:47 -0000, "Dave" <co*****@akamarketing.com> wrote:
I notice both unix and windows have the tree command for viewing a systems
files from the current dir downwards. Is there anyway in PHP which I could
use this command and make a tree with all the directories clickable? So
users could go to them directories?


May you could, but often it's better and safer to stick with native functions
rather than spawning external processes. See:

opendir()
readdir()

And use an array as a stack to read any subdirectories. e.g.

<?php
$baseDir = '.';
$dirStack = array($baseDir);

while (($currentDir = array_pop($dirStack)) !== null)
{
if ($dir = opendir($currentDir))
{
while (($file = readdir($dir)) !== false)
{
if ($file != '.' && $file != '..')
{
if (is_dir("$currentDir/$file"))
array_push($dirStack, "$currentDir/$file");

echo htmlspecialchars("$currentDir/$file") . "<br>";
}
}
}
}
?>

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
Ner dont reinvent the wheel

http://phptree.sourceforge.net/

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: t_pet422 | last post by:
Hi, I've been scouring the net and reading the PostgreSQL docs for a while now trying to learn how to create a recursive function in PL/pgSQL that will return a whole subtree given a starting...
7
by: Matt Kruse | last post by:
I've just put up a new script on my site: http://www.mattkruse.com/javascript/mktree/ This script combines javascript and some tricky CSS to create the easiest-to-implement...
2
by: My Internet | last post by:
Hello, I want to know if in PostgreSQL, there is a command equivalent to START WITH... CONNECT BY from Orcale? This command is used to traverse a tree. Thank you, Jean-Marc ...
6
by: Vinay | last post by:
Hi Everybody I have been looking out for a Function call tree command in Unix environment. Given a piece of source code(millions of lines), there is a function F1() calling F2() calling F3()....
25
by: prabhat143 | last post by:
Hi, Given a singly linked, null terminated list, how can it be converted to tree? Each node in the list has three attributes: it's ID, it's parent ID and of course, the next node it's pointing...
15
by: Foodbank | last post by:
Hi all, I'm trying to do a binary search and collect some stats from a text file in order to compare the processing times of this program (binary searching) versus an old program using linked...
1
by: Foodbank | last post by:
Hi, I'm currently teaching myself C data structures in preparation for a job transition and I've just passed the point in which radix sorting was covered in my book. I've recently finished a...
2
by: Alan Searle | last post by:
I would like to 'grab' certain directory trees and then store them in a table. At the moment, I writing my own VBA to do this but I cannot help thinking that there must already be something...
3
by: Peter | last post by:
Hi, I have a Class-Tree based on "Command-Pattern" eg. public class Calculator { .... } public abstract class command
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.