title: Create random string, check if it exists, if it does create a new one
body: <p>I want to generate a random string of about 5 characters long. I can create it ok, but I'm having trouble checking if it exists in an array (or database in real situation) and creating a new one if it does.</p>
  
  <p>I use a function like this to generate the string:</p>
  
  <pre><code>function rand_string(){
      return substr(md5(microtime()), 0, 5);
  }
  </code></pre>
  
  <p>But them I'm lost.</p>
  
  <ul>
  <li>I need to check if it exists already.</li>
  <li>If it does, make a new one</li>
  <li>And repeat</li>
  </ul>