Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6357613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:12:01+00:00 2026-05-24T23:12:01+00:00

I’m working with PHP here. I want to extract the text below a specific

  • 0

I’m working with PHP here.

I want to extract the text below a specific line number. The reason why I want I want to do this is to remove HTTP Header information from a CURL response.

Below is some code from sample response data:

HTTP/1.1 203 OK
Date: Tue, 23 Aug 2011 20:56:41 GMT
Server: Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4   Perl/v5.10.1
X-Powered-By: PHP/5.3.5
Set-Cookie: PHPSESSID=ke0uv5bm0mqjn3i3jad6n20co4; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Test-Header: This is my test header
Content-Length: 24
Content-Type: text/html

This is the get response

What I’d like to do is remove all the header information and return only my content i.e. “This is my get response”.

I’ve done this successfully with regular expressions, but I want to do something that simple clears the content above the main response, rather than match header content then replace with empty space.

Any ideas?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:12:03+00:00Added an answer on May 24, 2026 at 11:12 pm

    I did a little poking around and here’s what I came up with as a solution.

    To get the number of line numbers taken up by my header content I wrote the following code:

    $pattern_1_str = '/(http\/\d\.\d)\s+([\d]+)\s+([\w\-\/\'\"\(\)\\\. ]+)/i';
    $pattern_2_str = '/([\w\-]+)\:\s+(.+)/i';
    
    $matches_1_arr = array();
    $matches_2_arr = array();
    
    preg_match_all($pattern_1_str, $curl_response_res, $matches_1_arr);
    preg_match_all($pattern_2_str, $curl_response_res, $matches_2_arr);
    
    $line_count_1_str = count($matches_1_arr[0]);
    $line_count_2_str = count($matches_2_arr[0]);
    
    $line_num_offset_str = bcadd(1, bcadd($line_count_1_str, $line_count_2_str, 0), 0);
    

    And then to get content only, the following code will do that:

    $val_str_arr = array();
    $val_str_arr = explode("\n", trim($curl_response_res));
    
    $line_num_int = intval($line_num_offset_str);
    
    $val_str_slice_arr = array();
    $val_str_slice_arr = array_slice($val_str_arr, $line_num_int);
    
    $curl_response_content_only_str = implode("\n", $val_str_slice_arr);
    

    Where $curl_response_res is the response data as mentioned in my question above.

    I’m not sure how efficient this code is, but for simple and relatively short response data from CURL it looks like it’ll do ok.

    Thanks for the responses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.