Welcome Guest, Not a member yet? Register   Sign In
directory_map() not working as advertised
#1

[eluser]myerman[/eluser]
So I have a section of our web site in which I display a list of PDFs (basically, PDF'd versions of articles I've written in the past). I was using directory_map() to just read off all the names of the files in a single directory.

This morning, I got the bright idea to organize those PDFs into subfolders and then use directory_map() to also capture the names of the directories. The documentation says that subdirectory names are captured. NOT.

here's the code in my controller:

Code:
$data['links'] = directory_map('./downloads/samples/');

Here's what I get instead....shouldn't the names of the subdirs be the keys?

Code:
Array
(
    [0] => Array
        (
            [0] => oasis_of_culture(zoom).pdf
        )

    [1] => Array
        (
            [0] => hbm_best_use_of_technology.pdf
            [1] => hbm_telecommute.pdf
            [2] => basic_web_presence.pdf
            [3] => Grow and Diversify your Business Online.pdf
            [4] => hbm_equipment_startup.pdf
            [5] => HBM_grow_your_business_online.pdf
        )


    [2] => Array
        (
            [0] => Information architecture concepts.pdf
            [1] => Software_Development_the_Agile_Way.pdf
            [2] => Planning for Domino on iSeries.pdf
            [3] => Grid watch_ The importance of being stateful.pdf
        )
)
#2

[eluser]myerman[/eluser]
Hmmmmm. I guess if I had done an asort() instead of a sort() then perhaps the directory names wouldn't have been reset to 0, 1, 2, 3 to match the indexes? Wow, what a goof I am!
#3

[eluser]wiredesignz[/eluser]
Glad we could help :lol:
#4

[eluser]gtech[/eluser]
replies and buses:

you wait two months and then get two at once. thanks for posting the solution though.




Theme © iAndrew 2016 - Forum software by © MyBB