christo16 Posted June 4, 2008 Share Posted June 4, 2008 Hello, Lets say I have a variable that contains some text and xml. $file = "HTTP/1.1 207 Multi-Status Content-Length: 1341 Accept-Ranges: bytes Vary: accept-encoding Server: Twisted/2.5.0 TwistedWeb/[twisted.web2, version 0.2.0] TwistedCalDAV/2.0 (unknown) Last-Modified: Wed, 04 Jun 2008 21:18:37 GMT DAV: 1, access-control, calendar-access, calendar-schedule, calendar-availability, inbox-availability, calendar-proxy, calendarserver-private-events ETag: \"3D2D-594-484706AD\" Date: Wed, 04 Jun 2008 21:23:25 GMT Content-Type: text/xml Connection: close <?xml version='1.0' encoding='UTF-8'?> XML GOES HERE </multistatus>"; How do I strip out the text- from "HTTP/1.1 207 Multi-Status" to "Connection: close", including the blank line below connection close? Thanks Link to comment https://forums.phpfreaks.com/topic/108765-strip-wordslines-from-string/ Share on other sites More sharing options...
discomatt Posted June 4, 2008 Share Posted June 4, 2008 Please be more general... my guess is you want everything before <?xml removed? Link to comment https://forums.phpfreaks.com/topic/108765-strip-wordslines-from-string/#findComment-557966 Share on other sites More sharing options...
christo16 Posted June 4, 2008 Author Share Posted June 4, 2008 Yes I want to be able to remove all the headers and have only XML Link to comment https://forums.phpfreaks.com/topic/108765-strip-wordslines-from-string/#findComment-557969 Share on other sites More sharing options...
dsaba Posted June 5, 2008 Share Posted June 5, 2008 <?php $file = "HTTP/1.1 207 Multi-Status Content-Length: 1341 Accept-Ranges: bytes Vary: accept-encoding Server: Twisted/2.5.0 TwistedWeb/[twisted.web2, version 0.2.0] TwistedCalDAV/2.0 (unknown) Last-Modified: Wed, 04 Jun 2008 21:18:37 GMT DAV: 1, access-control, calendar-access, calendar-schedule, calendar-availability, inbox-availability, calendar-proxy, calendarserver-private-events ETag: \"3D2D-594-484706AD\" Date: Wed, 04 Jun 2008 21:23:25 GMT Content-Type: text/xml Connection: close <?xml version='1.0' encoding='UTF-8'?> XML GOES HERE </multistatus>"; $file = preg_replace('~(.+?)<\?xml\s*version=~s', '$1', $file); echo $file; ?> Anyone have anything better? Link to comment https://forums.phpfreaks.com/topic/108765-strip-wordslines-from-string/#findComment-557993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.