Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

Make money selling software. Check this out here

Hosted clickbank mall. Check this out here




   Misc

   Amazon

   Links

    


Random String

 

 

This example generates a random string from an array of characters

Code

<?php
// function to generate random strings
function RandomString($length=32)
{
$randstr='';
srand((double)microtime()*1000000);
//our array add all letters and numbers if you wish
$chars = array ( 'a','b','c','d','e','f');
for ($rand = 0; $rand <= $length; $rand++)
{
$random = rand(0, count($chars) -1);
$randstr .= $chars[$random];
}
return $randstr;
}
?>

and call it like this


<?php
echo RandomString(8);
?>

 

 


 

 

Example

badaeadfe



 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Disk file systems in VBScript(VB)
drive type(VB)
displays the browser info(Javascript)
a simple dialog box using swing(Java)
get the computer name(c)
save text to a file(VB)
Detect sound card(VB)
Factorial function(ASP)

    




Copyright © 2004 by programmershelp.co.uk