Saturday, 17 August 2013

I want to view all images inside a directory I'm using codeigniter directory helper

I want to view all images inside a directory I'm using codeigniter
directory helper

I used codeigniter default helper function to map the directory
$path = 'user_uploads';
$data = directory_map($path);
and i do a
var_dump($data);
and the result is
array(9) { [0]=> string(12) "SDC10027.JPG" [1]=> string(12) "SDC10028.JPG"
[2]=> string(12) "SDC10029.JPG" [3]=> string(12) "SDC10030.JPG" [4]=>
string(12) "SDC10031.JPG" [5]=> string(12) "SDC10032.JPG" [6]=> string(12)
"SDC10033.JPG" [7]=> string(12) "SDC10034.JPG" [8]=> string(12)
"SDC10035.JPG" }
what i need is i want to show each and every image in a web page like this.
<img src="<?php echo base_url() . 'user_uploads/'. $image; ?>"/>
$image is the image names that are read through the directory_map() function.
the only thing i need to know is how to take those directory_map() return
array image names to $image variable.

No comments:

Post a Comment