CodeIgniter Forums
Code compatible with CodeIgniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Code compatible with CodeIgniter (/thread-52460.html)



Code compatible with CodeIgniter - El Forum - 06-12-2012

[eluser]Gabi3xz[/eluser]
I have a code which extract images from a folder.
Code:
$dir = base_url().'images/user';
$file_display = array('jpg', 'jpeg', 'png', 'gif');

if (file_exists($dir) == false) {
   $images = 'nu sunt';
} else {
   $dir_images = scandir($dir);

   $images = '<div>';
    foreach ($dir_images as $file) {
     $file_type = strtolower(end(explode('.', $file)));
     if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) {
     $images .= '<a href="#"><img src="'.base_url().'/'.$dir.'/'.$file.'" alt="'.$file.'" /></a>';
     }
    }
   $images .= '</div>';
}
Says that it has certain functions compatible. "scandir"
What can I do?