- rand: documentation ( source)
<?php
function apikey( $length ) {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
$size = strlen( $chars );
for( $i = 0; $i < $length; $i++ ) {
$str= $chars[ rand( 0, $size - 1 ) ];
echo $str;
}
}
$apikey = apikey(32);
echo $apikey;