arrayobject and directory listing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Consolas
Forum Newbie
Posts: 13
Joined: Wed Apr 09, 2008 7:07 pm

arrayobject and directory listing

Post by Consolas »

Hello everyone!!!

I have this problem:

http://pastebin.com/m114f9992

Just to add a few more hints to the problem:

i've manage to get a tree of directorys going, with all hierachy perfect align

dir1
dir1.1
dir 2
(etc)

The problem is: they are not sorted out by name..someone told me i should use arrayobject class to do this...what i'm guessing is i've got to implement some kind of class that will sort out the variable $dir ( that is the result of the recursive directory listing function )

So, i'm calling it like this

$dir = new RecursiveIteratorIterator(new RecursiveDirIterator($directorio_call), true);

foreach ( $dir as $file ) {
etc etc


should it be something like before the for each

$sorted = new ClassThatSorts($dir)

$sorted->sort();

and then the for each?

how can i do this? i've been at a lot of foruns and mirc!

Please!!

Thank you very very very much!!

Ricardo
Consolas
Forum Newbie
Posts: 13
Joined: Wed Apr 09, 2008 7:07 pm

Re: arrayobject and directory listing

Post by Consolas »

Any ideas?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: arrayobject and directory listing

Post by RobertGonzalez »

What are you trying to do?
Consolas
Forum Newbie
Posts: 13
Joined: Wed Apr 09, 2008 7:07 pm

Re: arrayobject and directory listing

Post by Consolas »

Hello sir

I want to have this ( pic below - which i have ) sorted by name ( which i dont have ).

So i want to get all files and directorys using, for instance SPL and sort out the results.

I've bee told that SPL doesn't allowed that and i need to put the directorys inside an array and sort the array out.

Any ideas?

Image
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: arrayobject and directory listing

Post by RobertGonzalez »

You could use something like glob(), but the spl stuff works good too. I say search around here for author feyd and use the term directory iterator. He did something amazing once with that tool.
Post Reply