CodeIgniter Forums
Code compatible with CodeIgniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Code compatible with CodeIgniter (/showthread.php?tid=52460)



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?