Re: Reading Remote Files
| From: | Michal Thomka | Date: | Tue, 05 Dec 2000 17:40:52 +0000 |
| Subject: | Re: Reading Remote Files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28728@lists.php.net to get a copy of this message | ||
Hi Tom,
Try this piece of code
$remote=file("http://www.remoteserver.com/thefile.html");
// now you have the remote page in array $remote , 1 line -1 element
$long_string=implode($remote,'');
$without_chunk=ereg_replace('<!--Start\ border1-->(.+)<!--End\
border1-->','
',$long_string);
I hope this'll help you
br
Michal
--
****************************
Michal Thomka
Programmer/Developer
_______________________
surfEU.com GmbH
Nordbahnstrasse 36/1/3
A-1020 Wien
Tel: +43 1 9989777-208
Fax: +43 1 9989777-200
mailto: misko@surfeu.com
http://www.surfeu.at/
****************************
Tom Harris wrote:
> Hi folks,
>
> I'm having trouble working with a remote file. What I want to do is grab an
> HTML file from our partner's site, and remove a chunk of between two html
> comments <!--Start border1--> & <!--End border1--> and then display what's
> left of the file in the browser.
>
> The first problem is when I do fread it dies in the following code
>
> $filename="http://www.remoteserver.com/thefile.html";
> $fp=fopen($filename, "r") or die("couldn't open");
> $body=fread($fp, filesize($filename)) or die("couldn't read");
>
> I'm guessing it can't get the filesize from a remote system, is there a way
> around this?
>
> Of course after this problem is solved, I have to figure out how to cut out
> the chunk of text.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net