title: Getting a random object from an array in PHP
body: <p>First and foremost, forgive me if my language is off - I'm still learning how to both speak and write in programming languages. How I can retrieve an entire object from an array in PHP when that array has several key, value pairs? </p>
  
  <pre><code>&lt;?php
  
    $quotes = array();
    $quotes[0] = array(
      "quote" =&gt; "This is a great quote",
      "attribution" =&gt; "Benjamin Franklin"
    );
    $quotes[1] = array(
      "quote" =&gt; "This here is a really good quote",
      "attribution" =&gt; "Theodore Roosevelt"
    );
  
  function get_random_quote($quote_id, $quote) {
  
    $output = "";
    $output = '&lt;h1&gt;' . $quote["quote"] . '.&lt;/h1&gt;';
    $output .= '&lt;p&gt;' . $quote["attribution"] . '&lt;/p&gt;';
  
    return $output;
  } ?&gt;
  
  &lt;?php 
    foreach($quotes as $quote_id =&gt; $quote) {
    echo get_random_quote($quote_id, $quote); 
  } ?&gt;
  </code></pre>
  
  <p>Using array_rand and var_dump I'm able to view the item in the browser in raw form, but I'm unable to actually figure out how to get each element to display in HTML.</p>
  
  <pre><code>$quote = $quotes;
  $random_quote = array_rand($quote);
  var_dump($quote[$random_quote]);
  </code></pre>
  
  <p>Thanks in advance for any help!</p>