4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 PHP: Seperating Header and Code
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Iyonix
WebHelper
WebHelper


Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England

PostPosted: Sun Nov 17, 2002 6:26 pm (14 years, 11 months ago) Reply with QuoteBack to Top

Hi.

I am connecting to a server using fsockopen() and requesting a webpage. It gives me a header and then the page or image code etc:

Code:

HTTP/1.1 200 OK
Date: Sun, 17 Nov 2002 18:20:06 GMT
Server: Apache/1.3.27 (Unix) mod_gzip/1.3.19.1a mod_watch/3.13 Chili!Soft-ASP/3.6.2 PHP/4.2.3
X-Powered-By: PHP/4.2.3
Connection: close
Content-Type: text/html

<html>
<body>
<h1>This is a test page.</h1>
</body>
</html>


What I want is just the html code or the image code (depending on what I am requesting) and not the header. I was wondering how I could do this? I have been playing around with explode, but it hasn't really worked.
Any Ideas?

Thx
OfflineView User's ProfileFind all posts by IyonixSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Nov 17, 2002 7:07 pm (14 years, 11 months ago) Reply with QuoteBack to Top

What about this:

Code:
$html=explode('<html>', $name_of_variable);
$html='<html>
'.$html[1];


However, in this case, an include statement would do the job with less work...

________________________________
Image

Last edited by Daniel on Wed Nov 20, 2002 2:57 pm, edited 1 time in total
OfflineView User's ProfileFind all posts by DanielSend Personal Message
eKstreme
Ex Team Member



Joined: 12 Jan 2002
Posts: 11
Location: UK

PostPosted: Mon Nov 18, 2002 12:59 am (14 years, 11 months ago) Reply with QuoteBack to Top

Just to add to Daniel's post, the header is always seperated from teh code with two new lines... Test for \n\n or \r\n\r\n. But I think in your case, Daniel's answer is better suited....
OfflineView User's ProfileFind all posts by eKstremeSend Personal MessageVisit Poster's Website
jayant
Team Member



Joined: 07 Jan 2002
Posts: 262
Location: New Delhi, India

PostPosted: Wed Nov 20, 2002 11:42 am (14 years, 11 months ago) Reply with QuoteBack to Top

\n\n is a better option. you might have something before <html> tag, like <!doctype> etc.
Search for first two consecutive \n\n and split Smile

________________________________
Jayant Kumar
Member of the 4WebHelp Team
Nibble Guru - Computing Queries Demystified
GZip/ Page Compression Test
OfflineView User's ProfileFind all posts by jayantSend Personal MessageVisit Poster's WebsiteYahoo MessengerMSN Messenger
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.045523 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme