title: How do I automatically display the first google image on my page?
body: <p>I have a page that automatically retrieves two random entries from a MySQL database and asks the user to compare them every time the page is refreshed. How can I convert those two strings into the first google image result for them automatically? This is what I have so far:</p>
  
  <pre><code>&lt;?php //I retrieve the names and group names here//
  $firstpersonaName = (string) $row["personaName"];
  $firstpersonaGroupName = (string) $row["groupName"];
      $firstpersonaGroupNameForGoogle = preg_split('( )', $firstpersonaGroupName);
  ?&gt; //then convert any group names containing spaces into arrays here//
  
  &lt;?php  //then here I build the query that displays a google image page//
      $newname = '';
      foreach ($firstpersonaGroupNameForGoogle as $firstpersonaPartofGroupName) {
          $newname = $firstpersonaPartofGroupName . '+';
      }
      $newname = rtrim($newname, "+");
      echo "https://www.google.com/search?q=" . $firstpersonaName . "+" . $newname . '&amp;tbm=isch'; 
  ?&gt;
  </code></pre>
  
  <p>This gives me stuff like: <a href="https://www.google.com/search?q=charlie+always+sunny&amp;tbm=isch" rel="nofollow">https://www.google.com/search?q=charlie+always+sunny&amp;tbm=isch</a></p>
  
  <p>So how do I take that link and turn it into the link of the first image? Or any of the first couple really. (In this case: <a href="http://cdn3.denofgeek.us/sites/denofgeekus/files/sunny_0.jpg" rel="nofollow">http://cdn3.denofgeek.us/sites/denofgeekus/files/sunny_0.jpg</a>)</p>