FREE PHP Scripts and Snippets

Ready to use Free PHP scripts and snippets to use in your projects.
All Free Scripts & Snippets Complete PHP Scripts

Free PHP folder to gallery script

>> Share on Facebook & Impress your friends <<

100% Free PHP folder to gallery script. Just give the name of folder and it will generate gallery of all images found in the folder.

<?php

/*
PHP  SCRIPT (function / snippet)

NAME: Free PHP folder to gallery script

Just path the relative path of the folder to this PHP Script.

It will then generate a gallery from all images found in this folder.

It can generate gallery for .jpg, .gif, .png, .bmp and other image types also.

Very simple and easy to use.


*/


function folderToGalleryScript($image_folder_path){ 
// $image_folder_path contains tha path to the images folder


// Calculate the number of images in the folder
$number_of_images_in_folder = glob($image_folder_path . "*.{JPG,jpg,gif,png,bmp}", GLOB_BRACE);

//Open the image folder for looping through the images
$image_folder = opendir($image_folder_path);
 
 // I there are some images in the folder
if($number_of_images_in_folder > 0)
{
	//Loop through all images
 while(false !== ($image = readdir($image_folder))) 
 {
	 // Calculate path of image
  $image_path = $image_folder_path.$image;
  // Check extension
  $extension = strtolower(pathinfo($image ,PATHINFO_EXTENSION));
  
  // And if it is an image file, then show it
  if($extension=='jpg' || $extension =='png' || $extension == 'gif' || $extension == 'bmp') 
  {
	  
	  // <a> tag links to the image so that it can be seen alone in new window.
   ?>
            <a  target="_blank" href="<?php echo $image_path; ?>"><img src="<?php echo $image_path; ?>"  height="250" /></a>
            <?php
  }
 }
}
else
{
 echo "The folder did not have any images!";
}
closedir($image_folder);
} 


folderToGalleryScript('images/');


?>


Request Custom Snippet

Just $5 Onwards

 

Previously Ordered Snippets

Show all files in a folder along with their size. And at the end show the total space consumed.
Price $5 Order Now

I want a PHP directory browsing system by which I can browse folders inside a folder and move up and down the hierarchy.
Price $10 Order Now

I want PHP Script to create a recursive array of directory structure. This recursive array can be unlimited levels deep.
Price $5 Order Now

I want a PHP function to which I can pass a nested array and it will create a directory structure based on that.
Price $5 Order Now

PHP snippet to zip all sub folders inside a folder into separate zip files and save them in same folder. There are over 100 folders.
Price $5 Order Now

I want a directory backup script. It should zip a directory, add a random password to it and then copy it to some other folder.
Price $5 Order Now

Random PHP Scripts and Snippets

Make URLs in plain text clickable [PHP]

This is a simple PHP function to parse text provided and automatically hyperlink the links in the text.

[PHP] generate keywords from text function

This is a simple function written in PHP to generate keywords from any text. Just pass any free text to...

PHP - Extract all links from a web page

PHP Script to extract all links from a web page. This PHP Snippet reads the contents of a web page...

PHP Create thumbnail of an image

PHP Script to create thumbnail of any image (.jpg, .png and .gif). This create thumbnail function is ready to use....

Generate Random Password in PHP

PHP Script to Generate Random Password. You can set the list of characters that you want to be used in...

Detect Valid Email address with PHP

A very simple php snippet to check if an email id is valid or not. If the email address is...

Free PHP folder to gallery script

100% Free PHP folder to gallery script. Just give the name of folder and it will generate gallery of all...

Create URL Slug from text string [PHP]

PHP Script to create URL from string. It retails only URL Safe characters in the strings. So, now easily create...