01.
function
alphanumeric_rand(
$num_require
=8) {
02.
$alphanumeric
=
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'
,0,1,2,3,4,5,6,7,8,9);
03.
if
(
$num_require
> sizeof(
$alphanumeric
)){
04.
echo
"Error alphanumeric_rand(\$num_require) : \$num_require must less than "
. sizeof(
$alphanumeric
) .
", $num_require given"
;
05.
return
;
06.
}
07.
$rand_key
=
array_rand
(
$alphanumeric
,
$num_require
);
08.
for
(
$i
=0;
$i
<sizeof(
$rand_key
);
$i
++)
$randomstring
.=
$alphanumeric
[
$rand_key
[
$i
]];
09.
return
$randomstring
;
10.
}
11.
12.
echo
alphanumeric_rand(12);