Generate a unique ID 10 characters long - PHP
A PHP function to generate a unique ID 10 characters long based on the current UNIX timestamp (10 digits).
<?php
function gen_uniqid() {
$char[0] = "ABCDEFGHIJ";
$char[1] = "KLMNPQRSTU";
$char[2] = "VWXYZabcde";
$char[3] = "fghijklmnp";
$char[4] = "qrstuvwxyz";
$char[5] = "0123456789";
$arr = preg_split('//', time(), -1, PREG_SPLIT_NO_EMPTY);
$uniqid = "";
foreach($arr as $val) {
$str = $char[rand(0,5)];
$uniqid .= $str{$val};
}
return $uniqid;
}
echo gen_uniqid();
?>
0 Comments
