Version: 3
Type: Sample Code (HOWTO)
Category: HTTP
License: BSD License
Description: Grabs the URL of today’s User Friendly comic.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"> <HTML xmlns="http://ww.w3.org/1999/xhtml" xml:lang="en" lang="en"> <HEAD> <TITLE>Blank PHP</TITLE> </HEAD> <BODY> <p>Today's <a href="http://www.userfriendly.org/" target="_blank">User friendly</a> strip.<br> <a href="http://www.userfriendly.org/" target="_blank"> <?php if(!($myFile=fopen("http://www.userfriendly.org/static/","r"))) { echo "Sorry, the user friendly strip is not so friendly right now. Please try later."; exit; } while(!feof($myFile)) { $myLine.=fgets($myFile,10); } fclose($myFile); $start="<IMG ALT="Latest Strip""; $end="<!-- R4L 576x16 -->"; $start_position=strpos($myLine, $start); $end_position=strpos($myLine, $end)+strlen($end); $length=$end_position-$start_position; $myLine=substr($myLine, $start_position, $length); eregi_replace ("<!-- R4L 576x16 -->", "", "</a>"); echo $myLine; ?> </body> </html>