CodeIgniter Directory helper
×

CodeIgniter Directory helper

1842

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.

$this->load->helper("directory");

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.

Syntax:

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.

Example:

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

<?php
class Directory_map extends CI_Controller {

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

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

http://localhost/ci/index.php/Directory_map



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments