PHP forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
April 2024
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930    

Calendar Calendar

Latest topics
» Kabaddi, Kabaddi, Kabaddi, Kabaddi......PHP?
Generate Code EmptyFri Jul 22, 2011 1:37 pm by shyamsunder

» Thousands of Free PHP Scripts Recommended
Generate Code EmptyWed May 18, 2011 10:33 am by bizboy12

» PHP form validation problem?
Generate Code EmptyWed Jan 12, 2011 1:25 pm by simy202

» string wrap
Generate Code EmptySat Aug 02, 2008 2:06 pm by scvinodkumar

» retrieving current date rows
Generate Code EmptyTue Jul 15, 2008 3:25 am by scvinodkumar

» number in words
Generate Code EmptyTue Apr 29, 2008 3:10 pm by scvinodkumar

» Simple PHP Form Field Generator
Generate Code EmptyFri Apr 25, 2008 12:28 pm by scvinodkumar

» PHP password generator
Generate Code EmptyFri Apr 18, 2008 7:24 pm by scvinodkumar

» PHP Script to Extract Email Address from any text
Generate Code EmptyFri Apr 18, 2008 7:18 pm by scvinodkumar

Search
 
 

Display results as :
 


Rechercher Advanced Search

Affiliates
free forum
 


Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Generate Code

Go down

Generate Code Empty Generate Code

Post  scvinodkumar Sat Mar 29, 2008 10:16 pm

<?php
function generateCode($length=6) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789";
$code = "";
$clen = strlen($chars) - 1; //a variable with the fixed length of chars correct for the fence post issue
while (strlen($code) < $length) {
$code .= $chars[mt_rand(0,$clen)]; //mt_rand's range is inclusive - this is why we need 0 to n-1
}
return $code;
}
echo generateCode();
?>

scvinodkumar
Admin

Posts : 40
Join date : 2008-01-30

https://solutions.aforumfree.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum