title: Get random lines from text file
body: <p>I want to call random words from the <code>random.txt</code> as the user refreshes the page but I get <code>$word_array[0]</code> only and not any other $word_array[1..3]. </p>
  
  <p>random.txt</p>
  
  <pre><code>hello
  how
  are
  you
  </code></pre>
  
  <p>PHP code:</p>
  
  <pre><code>myfile = fopen("random.txt", "r") or die("Unable to open file!");
  $word_array = array(fgets($myfile));
  
  $word = rand(0,4);
  $lines[] = fgets($myfile);
  echo $word_array[$word];
  
  fclose ($myfile); 
  </code></pre>
  
  <p>What is the error?</p>
  
  <p>update: If loops can be avoided, and correct this code only.</p>