Last active
April 18, 2018 03:52
-
-
Save opnchaudhary/4995012 to your computer and use it in GitHub Desktop.
Random String Generator : Helper File for Codeigniter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
// ------------------------------------------------------------------------ | |
/** | |
* Random String Generator : Helper File for Codeigniter | |
* | |
* @author Paras Nath Chaudhary | |
* @link https://gist.github.com/opnchaudhary/4995012 | |
* | |
*/ | |
// ------------------------------------------------------------------------ | |
/* | |
Documentation: | |
============= | |
1. | |
$this->load->helper('rand_helper'); | |
$randomString=generateRandomString(); | |
echo $randomString; | |
2. | |
$this->load->helper('rand_helper'); | |
$randomString=generateRandomString(14); | |
echo $randomString; | |
*/ | |
if ( ! function_exists('generateRandomString')) | |
{ | |
function generateRandomString($length = 10) { | |
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
$randomString = ''; | |
for ($i = 0; $i < $length; $i++) { | |
$randomString .= $characters[rand(0, strlen($characters) - 1)]; | |
} | |
return $randomString; | |
} | |
} | |
/* End of file rand_helper.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hiiii.....I need help..... I want last three digit number (RNG)...I HAVE PERVIOUS NUMBERS IF ANYONE CAN HELP ME.........PLEASE...... Waiting for the response.......