title: array_rand function returns empty sometimes
body: <p>I want to make a little service.The service's main idea is to show one record from mysql table and it makes this per click at randomly.</p>
  
  <p>Here is the code that i wrote:</p>
  
  <pre><code>&lt;?php
  require'connection.php';
  
  $dbQueryFirst = $nesnePDO-&gt;prepare("SELECT CategoryID FROM Categories");
  $dbQueryFirst-&gt;execute();   
  while ($resultsFirst = $dbQueryFirst-&gt;fetch(PDO::FETCH_ASSOC)) 
  {
      $getidFirst[] = $resultsFirst;
      $puppet = array_rand($getidFirst);
      if ($puppet == null &amp;&amp; empty($puppet)) 
      {
          shuffle($getidFirst);       
      }       
  }
  
  $rndID = $puppet;
  
  $dbQuerySecond = $nesnePDO-&gt;prepare("SELECT * FROM Categories WHERE CategoryID = :CategoryID");
  $dbQuerySecond-&gt;bindParam(":CategoryID",$rndID);
  $dbQuerySecond-&gt;execute();
  $resultsSecond = $dbQuerySecond-&gt;fetchAll(PDO::FETCH_ASSOC);
  echo json_encode($resultsSecond);
  ?&gt;
  </code></pre>
  
  <p>First query is,get id's from db and take them into array.Second query,get the random id from the previous query's result and show the entire row of relevant id.And I got stuck at random function.
  If I need to explain this work with percentage for to be more clearly,</p>
  
  <ul>
  <li>Works well and get results %70</li>
  <li>get empty %20</li>
  <li>get null array <code>[]</code> %10</li>
  </ul>
  
  <p>I wanted the show the screenshots but system didn't give the permission because of my reputation.So,the final statement as usual,"I'm not so good at PHP.Any idea?" Honestly,any help would be appreciated.</p>