Random string
generates a random string from an array of characters
<?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);
?>
Related posts:
- Random XML feeds with PHP This example will display results from random XML feeds, note...
- random numbers This example shows how to produce random numbers in VB.net...
- dice game #include #include #include void main() { /*variables*/ int mydice1 ,mydice2...
- bubblesort routine # include # include void bubblesort(int array[],int size); void main()...
- Get stock quotes <?phpClass yahoo{function get_stock_quote($symbol){$url = sprintf(""http://finance.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgv"" ,$symbol);$fp = fopen($url, ""r"");if(!fp){echo ""error...
Related posts brought to you by Yet Another Related Posts Plugin.






















