MLUG: Re: [MLUG - DISCUSSION] PHP: Putting a remote file in a string
Re: [MLUG - DISCUSSION] PHP: Putting a remote file in a string
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
In case you all or future google searchers are curious, I solved the
problem by putting the file into a string very easily:
$rdf = join ('', file ($url));

That's from the manual, but searching the web its appears to be a problem.

I also created a short function which solved by parsing problems. It
returns from $haystack whats between $begin and $end. $offset is meant to
a pointer, so the next time you run ParseIt it does searches from the
position the previous ParseIt left off.

function ParseIt($begin, $end, $haystack, $offset = 0)
{
$StartPos = strpos($haystack, $begin, $offset);
$EndPos = strpos($haystack, $end, $offset);
$ParsedLength = $EndPos - $StartPos;
$offset=$EndPos + FindLength($end);
return substr($haystack, $StartPos, $ParsedLength);
}

The whole source for my RDF reading program is at:
http://mlug.missouri.edu/~eean/bk/new/rdf.php.txt

Ian Monroe
http://mlug.missouri.edu/~eean/

On Tue, 29 Jan 2002, Igor Izyumin Jr. wrote:

> On Tuesday 29 January 2002 21:39, Ian Monroe wrote:
> > I need to put a webpage into a string variable.
> >
> > The below snipet has one major problem. On the
> > $rdf = fread ($fd, filesize ($url)); line, you can not find the filesize
> > of a URL. What can I use instead? I could put in a really big number, or
> > write the webpage to the disk and find the file size of that, but both
> > seem kludgy.
> Maybe read the page 1 byte at a time until you get to EOF?  That's the 
> standard way to do it, I think.
> Something along the lines of:
> while($rdf .= fread($fd, 1));
> should work.
> -- 
> -- Igor
> --


--
To unsubscribe, go to http://mlug.missouri.edu/members/edit.php

Archives are available at http://mlug.missouri.edu/list-archives/