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

  • SEARCH
  • Home
  • 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 7011523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:08:18+00:00 2026-05-27T22:08:18+00:00

I am trying to parse PHP error log. The issue is that breaking the

  • 0

I am trying to parse PHP error log. The issue is that breaking the file by \n doesn’t work.

explode(PHP_EOL, $log)

This doesn’t work because there are some error messages that contain \n by itself.

How to break such file by lines then?

Extract of the problematic log:

[04-Jan-2012 21:28:48] PHP Notice:  Use of undefined constant AY_FACEBOOK_TAB_URL - assumed 'AY_FACEBOOK_TAB_URL' in /var/www/[hidden]/default.layout.tpl.php on line 36
[04-Jan-2012 22:38:02] PHP Notice:  Use of undefined constant AY_FACEBOOK_TAB_URL - assumed 'AY_FACEBOOK_TAB_URL' in /var/www/[hidden]/default.layout.tpl.php on line 36
[04-Jan-2012 23:43:33] PHP Warning:  file_get_contents(https://graph.facebook.com/4294967295/picture?type=large): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error
 in /var/www/[hidden]/result.tpl.php on line 11
[04-Jan-2012 23:43:33] PHP Notice:  Undefined variable: image in /var/www/[hidden]/result.tpl.php on line 20

Notice the line break after HTTP/1.0 500 Internal Server Error.

  • 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-27T22:08:19+00:00Added an answer on May 27, 2026 at 10:08 pm

    Use regular expression to match the start of the line. It usually is a date/time (timestamp).

    This code works for me:

    <?php
        $content = file_get_contents('/var/log/php-log.log');
    
        var_dump(preg_split('/\[\d\d-\w{3}-\d{4}\s+\d\d:\d\d:\d\d\]/', $content));
    

    But though i am splitting with the line-start pattern, the first result item would be empty.

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

Sidebar

Related Questions

I am beginner in PHP. I am trying to parse this xml file. <relationship>
I'm trying to parse an XML file using PHP, but I get an error
I'm trying to parse an xml file that contains accents, but I get this
I am trying to parse an xml document I created in a php file
I'm trying to parse a page for which I've to first log into that
I am trying to parse XML using PHP DOM and then insert this data
I'm trying to parse a moderately large XML file (6mb) in php using simpleXML.
I am getting this error: PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING When I
Iam trying to parse rss feed from particular url... here is my php file
I am trying to parse a string of HTML tag attributes in php. There

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.