<?php
function randStr($num){
$chars = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9');
for($i=0;$i<=$num;$i++){
$cs = round(rand(1,count($chars)));
$up = rand(0,2);
if($up<=1){
$str.=strtoupper($chars[$cs]);
}else{
$str.=$chars[$cs];
}
}
return $str;
}
echo randStr(30);
?>
So to call it, you'd use something like this:
echo randStr(30); That would display a random string with 30 characters.
Cheers.
discuss this topic to forum
