current weather favicon


/ Published in: PHP
Save to your folder(s)

requires MagpieRSS. copy and paste into html head tag, then edit zipcode variable to reflect what weather you want to show.


Copy this code and paste it in your HTML
  1. <?php
  2. $zipcode = 94704;
  3. require_once('magpierss/rss_fetch.inc');
  4. $url = "http://rss.weather.com/weather/rss/local/" . $zipcode . "?cm_ven=LWO&cm_cat=rss&par=LWO_rss";
  5. $rss = fetch_rss($url);
  6. $desc = array();
  7. foreach ($rss->items as $item) {
  8. $desc[] = $item['description'];
  9. }
  10. $icon = substr($desc[0],(stripos($desc[0], "src=")+5),(stripos($desc[0], "alt=\"\"")-(stripos($desc[0], "src=")+5)-2));
  11. echo "<LINK REL=\"SHORTCUT ICON\" HREF=\"" . $icon . "\">";
  12. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.