Jump to content

Strip Words/Lines from string


christo16

Recommended Posts

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
Share on other sites

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.