Jump to content

Regoch2

New Members
  • Posts

    4
  • Joined

  • Last visited

About Regoch2

  • Birthday 03/15/1977

Profile Information

  • Gender
    Male
  • Location
    Ugljan; Croatia

Regoch2's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. http://php.net/manual/en/array.sorting.php Try look here.
  2. This is what I get working! Thanks spiderwell for direction! <?php $folder = 'images/galeria'; // Choose directory $extensions = array('jpg','jpeg','gif','png'); $slika = scandir($folder); sort($slika); // Sort the array foreach($slika as $key => $value) { $get_extensions = explode(".",$value); $ext = $get_extensions[count($get_extensions) - 1]; // Only include files with desired extensions if (in_array($ext, $extensions)) { $title = substr($value, 0,strrpos($value,'.')); // Get filename for alt echo '<img src="/'.$folder.'/'.$value.'" width="893" height="597" alt="'.$title.'" /> '; } } ?>
  3. I find this script online for geting images from directory. Is there any way to change code to get it align by name? With this code I get random align! Thanks! <?php /* Configuration Start */ $orig_directory = 'images/galeria'; /* Configuration end */ $allowed_types=array('jpg','jpeg','gif','png'); $file_parts=array(); $ext=''; $title=''; $i=0; /* Opening the image directory and looping through all the thumbs: */ $dir_handle = @opendir($orig_directory) or die("There is an error with your image directory!"); $i=1; while ($file = readdir($dir_handle)) { /* Skipping the system files: */ if($file=='.' || $file == '..') continue; $file_parts = explode('.',$file); $ext = strtolower(array_pop($file_parts)); /* Using the file name (withouth the extension) as a image title: */ $title = implode('.',$file_parts); $title = htmlspecialchars($title); /* If the file extension is allowed: */ if(in_array($ext,$allowed_types)) { /* Outputting each image: */ echo '<img src="/'.$orig_directory.'/'.$file.'" width="893" height="597" /> '; } } /* Closing the directory */ closedir($dir_handle); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.