- uniqid: documentation ( source)
- preg_replace: documentation ( source)
<?php
// Force an all-numeric uniqid (happens at certain system clock values)
$my_key = uniqid("\x00");
$my_key = preg_replace('/[a-zA-Z]/', "4", $my_key);
$my_key .= "a";
$var[$my_key] = TRUE;
foreach($var as $key => $val)
{
if ($key === $my_key) {
echo 'You got it right';
} else {
echo 'You got it wrong';
}
}