Screen Shot for Thumnbails


Conn Warwicker



Portfolio

Scripts and Websites I've made using PHP and MySQL mainly.

Snippets

Code snippets and mini tutorials

Contact

Contact me if you have any questions or queries



Home / Snippets / random_string

This section is new and undergoing snippet addition, as of 13/6/11

Random String



Can be used for unique tracking IDs, passwords, etc...

<?php
 function generateRandomString()
    {

    $list = "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMm0123456789NnOoPpQqRrSsTtUuVvWwXxYyZz0123456789"; // The random characters to choose from
    $key = '';
    $length = 10; // Length you want the string to be

     for($i=0;$i<$length;$i++)
     {
     $key .= $list{rand(0,strlen($list)-1)};
     }

    return $key;

    }
?>


Change the characters to choose from and the length of the string as you see fit.

Leave a Comment


Comment

All fields are required

Your Name


Your Email Address


Your Comment


Human Validation

What animal is this above:






Comments


No Comments Have Been Made