<?php
$key = wp_rand(0, strlen($chars) – 1);

echo '$key';
function wp_rand( $min = 0, $max = 0 ) {
global $rnd_value;
if ( strlen($rnd_value) < 8 ) {
$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) );
$rnd_value .= sha1($rnd_value);
}

$value = substr($rnd_value, 0, 8);

// Strip the first eight, leaving the remainder for the next call to wp_rand().
$rnd_value = substr($rnd_value, 8);
$value = abs(hexdec($value));


if ( $max != 0 )
$value = $min + (($max – $min + 1) * ($value / (4294967295 + 1)));

return abs(intval($value));
}

?>