'; echo "\n\n\n"; echo " $title\n"; echo ' '; echo "\n\n\n"; echo "\n"; echo "$body\n"; echo "
\n

Back to Problem Set index page

\n"; echo "\n"; echo ""; } // Construct title and body-content for page rendering function construct_page ($htmlstring) { $now = date("Y-m-d H:i:s"); $title = "The top news item in mbl.is - $now"; $body = "" ."

Problem Set 5: D - Do it yourself

" ."

Currently ($now) the top story in the Icelandic news site mbl.is is:

" ."$htmlstring"; render_page ($title, $body); } // Get the HTML page that contains the dollar exchange rate $content = file_get_contents ("http://www.mbl.is"); // The pattern to use with the ereg command $pattern = '(

.*

)'; if ( eregi($pattern,$content,$result) ) { // there is a match $htmlstring = "$result[1]"; construct_page ($htmlstring); } else { # no match; something went wrong! render_page ("Unavailable service", "The service is unavailable!

" ."Please send me an thorarinn@itu.dk."); } ?>