ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
, Retrieve names of existing directories only and put them in an array and sort them. The following php script works for the main directory - my main domain (http://www.flatstorentlive.co.uk) because the script is shown at the bottom and returns the correct values "Fulham" and "Notting Hill". But when i use the same script for the subdomains which each have their own index page i get nothing! Even though the variable $dir is set and it cant change! The other pages are (http://fulham.flatstorentlive.co.uk) and (http://nottinghill.flatstorentlive.co.uk)
"readdir" returns the name of what it finds inside the directory without the directory name first. So your script only works if current directory is /home/public_html. To fix:
Edit:
Another option is to just put a "chdir($dir)" before the opendir. I see that later in your script, you assume the filenames don't have a directory prefix.
Thanks Guttorm! It sort of works but another problem has arisen! The changes i made that you suggested i came up with these results:
/HOME/FLATSTOR/PUBLIC_HTML/. /HOME/FLATSTOR/PUBLIC_HTML/.. /HOME/FLATSTOR/PUBLIC_HTML/CGI BIN /HOME/FLATSTOR/PUBLIC_HTML/FULHAM /HOME/FLATSTOR/PUBLIC_HTML/NOTTING HILL /HOME/FLATSTOR/PUBLIC_HTML/SUSPENDED.PAGE
WHICH IS EXCELLENT, but...
I am new to php, so how do i strip away the path, to be left with just the the final directories as names like this:
Hello Guttorm, sorry to bother you again but it doesn't seem to work!!! Not the basename but the script! It was working a minute a go with your suggestion but now it doesn't here is all the changes i made:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.