Welcome Guest, Not a member yet? Register   Sign In
Array troubles
#1

[eluser]Jamie Rumbelow[/eluser]
I've got a huge annoyance, i'm using the directory_map function in the directory helper to get an array of files, but I dont know what to do next. I'm trying to just list the file names, but I dont have anything to reference to in the index.

I've tried a foreach function, with an incrementing variable, and a for loop, but neither worked.
#2

[eluser]Seppo[/eluser]
I don't understand the problem... The only thing you want are the files? In that case you could use "get_filenames" function, in the file helper, instead... Equally, the usage is simple
Code:
$this->load->helper('directory');
        $map = directory_map(APPPATH);

        foreach ($map as $k => $v)
        {
            if (is_array($v))
            {
                echo 'Directory: ' . $k;
                // in $v we have another array with all the files, recursively.
            } else {
                echo 'File: ' . $v;
            }
            echo '<br />';
        }




Theme © iAndrew 2016 - Forum software by © MyBB