I have made a random character generator, but how can I check if an result already exist in the database?
E.g., if I want 5000 results, and 1 result is equal to an result in the database, it must create a new result in the for-loop.
$previous = array();
for ($i=1; $i<=$quantity; $i++){
$unique_found = false;
while(!$unique_found){
$a = substr(str_shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 4);
$b = substr(str_shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 4);
$c = substr(str_shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 4);
$d = substr(str_shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 4);
$code = "$a-$b-$c-$d";
if(!in_array($code,$previous)){
$unique_found = true;
$previous[] = $code;
echo .$code .'<br>';
}
}
}