Image game

By | July 31, 2010

We were playing games last night and I was reminded of a Swedish TV game show where each team of contestants was shown five images and had to come up with a song that related to three of the images.

So we came up with the idea to do that at home with a laptop and randomized images from the web. So I made a page that does that!

It simply fetches five images from the flickr’s random “interesting photos from the last 7 days” using this function (derived from this post):

$doc = new DOMDocument();
$xpath = new DOMXpath($doc);
  $src = $xpath->query("//td[@class='Photo']/span/a/img/@src");
  $url = $xpath->query("//td[@class='Photo']/span/a/@href");

  print '<a href="'.$url->item(0)->nodeValue.'">
      <img src="'.$src->item(0)->nodeValue.'" /></a>';
  print '<a href="'.$url->item(1)->nodeValue.'">
      <img src="'.$src->item(1)->nodeValue.'" /></a>';
  print '<a href="'.$url->item(2)->nodeValue.'">
      <img src="'.$src->item(2)->nodeValue.'" /></a>';
  print '<br />';
  print '<a href="'.$url->item(3)->nodeValue.'">
      <img src="'.$src->item(3)->nodeValue.'" /></a>';
  print '<a href="'.$url->item(4)->nodeValue.'">
      <img src="'.$src->item(4)->nodeValue.'" /></a>';

Leave a Reply

Your email address will not be published.