Getting x amount of items from array
<p>I'm doing this task in school where I'm to do something with arrays and loops in PHP. </p>

<p>What I've done so far is make this piece of code, that makes an array with names from a separate text-file, and chooses a random name from that array. </p>

<p>What I'd like it to do now is to display x amount of random names. The amount of names can be chosen in an input field, preferably with a for or while loop (those are the ones I know somewhat). </p>

<p>Here is my code (Don't think the text-file is necessary. If it is, just let me know):</p>

<pre><code>&lt;form method="POST"&gt;
    How many names do you need?  
   &lt;input type="number" name="amount" min="1" max="28"&gt;&lt;br&gt;&lt;br&gt;
   &lt;input type="submit" name="proceed" value="Get name(s)"&gt;
&lt;/form&gt;

&lt;?php       
    $text = file_get_contents("names2t.txt"); 
    $Array = explode("\n", $text); 
    $randNameNum = array_rand($Array); 
    $randPhrase = $Array[$randNameNum]; 

    if (isset($_POST["proceed"])){
        echo $randPhrase;
    }   
?&gt;
</code></pre>

<p>Is it possible to do what I'm asking?</p>