CodeIgniter Directory helper

CodeIgniter Directory helper


Directory helper contains functions that help us for working with directories.

Related Topics:

Codeigniter Interview Questions
CodeIgniter Text helper
CodeIgniter Email helper

Loading this Helper:

Use the given line in your controller or model file to load the Directory helper.


The following functions are available in this helper:

1 directory_map(): This function is used to map all folders of the given directory. Sub-folders contained within the directory will be mapped as well.


directory_map($source_dir[, $directory_depth = 0[, $hidden = FALSE]]);

Parameter Description:

  • $source_dir (string) – Path to the source directory
  • $directory_depth (int) – Depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
  • $hidden (bool) – Whether to include hidden directories

The return type of this function is an array and it returns an array of files.


Step 1 Open the application/controllers directory and create a new controller file Directory_map.php

class Directory_map extends CI_Controller {

public function index() {
$this->load->helper('directory'); //load directory helper
$map = directory_map('application/views');
echo "<pre>";

Step 2 Open the given URL into the browser to see the result.


Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments