title: PHP - Generating random integers within specified range from a key
body: <p>I have a set of questions with unique IDs in a MySQL database.
  Users also have a unique ID and are to answer these questions and their answers are saved in the database.</p>
  
  <p>Now, I want users to get 5 non-repeating uniquely and randomly picked questions from the pool of available ones (let's say 50) based on users ID. So when a user with id 10 starts answering his questions, but stops and wants to return later to the same page, he will get the same questions as before. A user with id 11 will get a different random set of questions, but it will always be the same for him and different from all other users.</p>
  
  <p>I found that random.org can generate exactly what I need with their sequence generator that generates a random sequence of numbers based on provided ID:
  <a href="https://www.random.org/sequences/?min=1&amp;max=50&amp;col=1&amp;format=plain&amp;rnd=id.10" rel="nofollow">https://www.random.org/sequences/?min=1&amp;max=50&amp;col=1&amp;format=plain&amp;rnd=id.10</a>
  But I would like the generation to be done locally instead of relying random.org API.</p>
  
  <p>So, I need to generate 'X' unique random integers, within specified range 'Y' that are generated based on supplied integer 'Z'. I should be able to call a function with 'Z' as parameter and receive back the same 'X' integers every time.</p>
  
  <p>I need to know how to replicate this generation with PHP code or at least a push or hint in a direction of a PHP function, pseudo-code or code snippet that will allow me to do it myself.
  Thank you in advance!</p>