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] Time ago calculation function

It is a very nice PHP time ago function. You gave pass any date to it and it will tell...

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

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

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

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.

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

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