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 7845927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:24:28+00:00 2026-06-02T17:24:28+00:00

I am reading log files that have been compressed with gzip in a php

  • 0

I am reading log files that have been compressed with gzip in a php script. Nothing is missing from the text, but all of the instances of multiple spaces have been reduced to a single space.

Here is an example of the output:

+-----------------------------------------------------------------------------+
| Exit Status : 1 |

When it should have looked like this:

+-----------------------------------------------------------------------------+
| Exit Status : 1                                                             |

Here is the relevant part of the script I think:

$lines = gzfile("$filename.gz");

# If the file is empty, say that to be more user friendly
if($lines == "") {
    echo "File empty";
} else {
    echo "<div style=\"font-family:courier new;font-size:12pt\">";
    foreach ($lines as $line) {
        echo nl2br($line);
    }
    echo "</div>";
}

I also tried it without nl2br, just as a test, and the spaces were still reduced to one. The file is intact as I viewed it with zcat in a terminal just to be sure something hadn’t actually written the file incorrectly. Any ideas?

  • 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-06-02T17:24:28+00:00Added an answer on June 2, 2026 at 5:24 pm

    Since you’re outputing HTML markup, I presume you’re viewing the output of your PHP script in a web browser. If this is the case, you’re encouring a quirk of HTML, not PHP. Specifically, web browsers render any expanse of whitespace as one space. It’s how HTML works.

    To view all the spaces, you need to wrap the output in <pre></pre> tags.

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

Sidebar

Related Questions

I have a log file that I am reading to a string public static
I am reading log files but not all lines want to be processed straight
I've been working on a log viewer for a Rails app and have found
I am developing a script to read and search log files for a big
I have to create a C# program that deals well with reading in huge
I've been reading on in particular 'error logging' And I have come up with
I have a file that I'm using to log IP addresses for a client.
I've been reading that people face problems when using the exit function in their
We have pretty large files, the order of 1-1.5 GB combined (mostly log files)
I have been reading a LOT of google posts and StackOverflow questions about how

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.