![]() |
Array diplaying Folder on top ?
Good day,
here I'm working on an array which read a directory and list the files and folders recursively. I'm trying to display in bold , and on top of all files, all the folders. PHP Code:
|
Here, I fixed it for you. I tested this on my /etc/ntp/ directory so just change it to whatever yours is.
Code:
<?php/etc/ntp/ntp2 /etc/ntp/step-tickers /etc/ntp/keys /etc/ntp/ntpservers |
Nice, it show the folder in bold, can I make the folder list first and then the files.
|
Quote:
But the current code shows the folders first in bold and the files in regular format... |
I do have a question for you.
You create this array to hold the data: $results = array(); But I don't see anywhere in the function where you actually send the data to the $results array variable. Does PHP implicitly somehow do this behind the scenes? Thanks.. |
I echo ed them before, yes, you are right.
Learning... |
You are right, I have ech-ed them before so the is no point for this line I think now.
|
RESOLVED
PHP Code:
|
Looks much cleaner....
I know that my code wasn't clean earlier but I knew that you would get the point and clean it up.... |
I have a few comments on your code.
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
Quote:
|
we can condense it further with the SPL DirectoryIterator:
PHP Code:
|
Quote:
|
Maybe I'm just misreading this thread but I think Peuplarchie is asking for the folders to be displayed first (in bold) and then the files afterwards.
Using the yummy SPL approach we can just iterate over the directory contents twice: PHP Code:
|
| All times are GMT. The time now is 05:50 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0