On 2010-11-26, at 7:33 PM, Adam Richardson <simples...@gmail.com> wrote:
> On Fri, Nov 26, 2010 at 7:03 PM, Kirk Bailey <kbai...@howlermonkey.net>wrote:
>
>> Hello all, my name is Kirk Bailey, and I am new to php, so please be
>> forbearing. I code in python, and am trying to learn this language as our
>> new client runs a web business based in it.
>>
>> I need a routine that will return a list of every directory immediately
>> under the current directory- but nothing else, just a list of directories, 1
>> level deep, NO FILES, no listing of current dir or prior dir either.
>>
>> Now in python, I would use os.walk, and use the list of dirs and throw the
>> other 2 lists away, but this ain't Kansas anymore. Does php even DO lists?
>>
>> Um, a list is a 1 dimenional array, if have a list ALIST and you plug in 3,
>> you get back the contents of cell 3 in the list, whaqtever that content is.
>> so if cell 3 in a 6 celled list was "Ruby" then ALIST[3] would return the
>> string "ruby".
>>
>> It's easy to iterate lists. For instance:
>>
>> print '<ul>'
>> for dir in ALIST:
>> print '<li><a href=\"/dir>",dir,'</a>
>> print '</ul>
>>
>> This would let me produce an ordered list of directories, each a link to
>> that directory.
>> This way, when a client installs a new product, the home page area listing
>> products offered automatically updates.
>>
>> Further embellishment would let me replace the dir name with a BRIEF
>> description from a descriptor file read from that dir. Now how to do this in
>> php?
>>
>> --
>> end
>>
>> Very Truly yours,
>> - Kirk Bailey,
>> Largo Florida
>>
>> kniht +-----+
>> | BOX | +-----+ think
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> To get you started:
>
> function get_directories($path)
> {
> $files_and_dirs = scandir($path);
> $dirs = array_filter($files_and_dirs, function($elem) { return
> is_dir($elem); });
> // $dirs also contains "." and "..", but you can get rid of them quite
> easily
> return $dirs;
> }
>
> Happy coding :)
>
> Adam
>
> --
> Nephtali: PHP web framework that functions beautifully
> http://nephtaliproject.com
Code igniter, a php framework can do this with one call. It could be worth
looking into
Bastien Koert
905-904-0334
Sent from my iPhone
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php