Page 1 of 1

arrayobject and directory listing

Posted: Wed Apr 09, 2008 7:11 pm
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

Re: arrayobject and directory listing

Posted: Thu Apr 10, 2008 10:20 am
by Consolas
Any ideas?

Re: arrayobject and directory listing

Posted: Thu Apr 10, 2008 3:49 pm
by RobertGonzalez
What are you trying to do?

Re: arrayobject and directory listing

Posted: Thu Apr 10, 2008 5:13 pm
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

Re: arrayobject and directory listing

Posted: Thu Apr 10, 2008 5:38 pm
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.