I was just wondering if it is possible to remove a value from an external .txt file once it is randomly chosen.
// Opens file with key values
$randomkeys = file('keys.txt');
// Takes keys from file and puts it into an array
$random_keys = array_rand($randomkeys, 2);
// Outputs the random key chosen
echo "Your code is: ";
echo $randomkeys[$random_keys[0]];
This is the code I am currently using and it works by reading the file that includes all the keys and then it is put into an array that would later be shown to the user that is using the site.
What I want to add to this is that when the user views the site that the key shown to them will be removed from the list so no one else can get that same key.
Aucun commentaire:
Enregistrer un commentaire