title: How to remove a value from an external text file if it is used PHP
body: <p>I was just wondering if it is possible to remove a value from an external .txt file once it is randomly chosen.</p>
  
  <pre><code>// 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]];
  </code></pre>
  
  <p>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.</p>
  
  <p><a href="https://i.stack.imgur.com/2j6g3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2j6g3.png" alt="Screenshot of keys.txt file contents"></a></p>
  
  <p>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.</p>