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

Generate Random Password in PHP

>> Share on Facebook & Impress your friends <<

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

<?php

/*

This function generates a random password.

It can contain any set of characters that you specify.

You can also control the length of generated password.

*/


function simplePasswordGenerator($length) {
	
	
	
	// This is the list of characters that you want to use for generating random password
    $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.-+=_,!@$#*%<>[]{}';
	
    $password = array(); //$password as an array, which will later be converted to string
    $alphaLength = strlen($characters) - 1; //This is number up to which array index runs
    
	for ($i = 0; $i < $length; $i++) {
        $n = rand(0, $alphaLength);
        $password[] = $characters[$n];
    }
    return implode($password); //turn the array into a string
}


// Calling the function
$length=8;
echo simplePasswordGenerator($length);

?>


Request Custom Snippet

Just $5 Onwards

 

Previously Ordered Snippets

PHP code to generate password which contains at least one small letter, one capital letter, one number and one special character.
Price $5 Order Now

I want a random Credit Card number generator.
Price $5 Order Now

I want a PHP function to generate random email addresses.
Price $5 Order Now

I want a random IP address generation code. I must be a PHP function.
Price $5 Order Now

Random PHP Scripts and Snippets

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....

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...

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...

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.

Extracting all numbers from a String [PHP]

This PHP function extracts all numbers from a String and prints them as a comma separated list of numbers. Ready...

PHP extract multiple emails from text

PHP Script to scan a text and extract all email ids contained in the text. It outputs email addresses as...

PHP Code to list all files in a folder

This PHP Code snippet lists all files in a folder and hyperlinks them accordingly. Very clean, easy to use function....