NYCPHP Meetup

NYPHP.org

[nycphp-talk] Re: [liphp] userfriendly.org

Daniel Kushner nyphp at websapp.com
Fri Jul 11 22:54:16 EDT 2003


Hans,

You know that I believe that regex's save the world :)
Here's a little something from me:

function getLatestCartoon() {
	preg_match("~ALT=\"?Latest Strip\"?.*SRC=\"?([^\"]+)\"?~i",
file_get_contents('http://www.userfriendly.org/'), $arr);
	return $arr[1];
}

echo getLatestCartoon();

--Daniel



> -----Original Message-----
> From: talk-bounces at lists.nyphp.org
> [mailto:talk-bounces at lists.nyphp.org]On Behalf Of Hans Zaunere
> Sent: Friday, July 11, 2003 4:34 PM
> To: liphp at liphp.org
> Cc: talk at lists.nyphp.org
> Subject: [nycphp-talk] Re: [liphp] userfriendly.org
>
>
>
>
> Aram Mirzadeh wrote:
>
> > Well I found a LWP/Perl program at: http://develooper.com/code/ufget/
> > But no PHP version, I would need to run this in cron during the morning
> > to cache it locally.  I was hoping to be able to do it dynamically with
> > php.
> >
> > Well if anyone finds one let me know, otherwise I'll try to write one in
> > the next couple of days.
>
> Not the prettiest, easily fooled and generally ugly... but it
> seems to work for now:
>
>
> function getuflatest() {
>    $ufpage = implode('',file('http://www.userfriendly.org'));
>    $latestpos = strpos($ufpage,'Latest Strip');
>    $uforgpos = strpos($ufpage,'http://www.userfriendly.org/',$latestpos);
>    $gifpos = strpos($ufpage,'.gif"',$uforgpos);
>    $uflatest = substr($ufpage,$uforgpos,$gifpos-$uforgpos+4);
>
>    return $uflatest;
> }
>
>
> H
>
>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk





More information about the talk mailing list