Thursday, 15 October 2015

PHP - RAND Function to generate Random String

PHP Code for the Random String Generation

<?php

function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
echo generateRandomString();


?>

Share:

1 comment:

  1. To fulfill your online store design & functionality requirements Hire WordPress WooCommerce Developer who are expert in programming and helps you in reach out your business goals. You can Hire WooCommerce Developer from our company from our company in affordable price. we are renowned for best quality solutions within goven deadline so hire dedicated WooCommerce Experts India make your online marketplace a unique one that attracts everyone and grows your online sales. our company has Expert WooCommerce Programmers in India that have potential to take challanges relevant to their skills.

    ReplyDelete

Blogger Tutorials

Blogger Templates

d-koder - Web Developer / Security Specialist / Penetration Tester I would like to write tutorials about the issue we use to get while coding something. Hope these small tuts will help developers worldwide. > Website

Interested In -

Html/Css
PHP
Javascript
Jquery
Ajax
JSON
GITHUB