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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:27:09+00:00 2026-05-27T13:27:09+00:00

I am printing a article with spaces inside the article. Text inside article has

  • 0

I am printing a article with spaces inside the article.
Text inside article has HTML tags also,so i am using htmlentities before echo.

But problem is that display does’t show spaces on the browser.
What is the problem with these commands?

Can someone please suggest me a better option?

DB update command:

 mysql_real_escape_string($text, $db)

Article display command:

echo nl2br(htmlentities($row_page['text']));

Example: displayed text is pretty ugly

Real text and i am expecting same:

dbus-1/                   libcom_err.so.2@                     libglib-2.0.so.0@            liblvm2cmd.so.2.02*      libpopt.so.0.0.0*
device-mapper/            libcom_err.so.2.1*                   libglib-2.0.so.0.2200.5*     libm-2.12.so*            libproc-3.2.8.so*
firmware/                 libcrypt-2.12.so*                    libgmodule-2.0.so.0@   
  • 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-27T13:27:10+00:00Added an answer on May 27, 2026 at 1:27 pm

    HTML collapses all whitespace (spaces or newlines or tabs) into a single space. You can work around it by replacing ' ' with '  ', for example:

    echo str_replace('  ', '  ', nl2br(htmlentities($row_page['text'])));
    

    But even cleaner is to just have the browser use pre formatted whitespace:

    <pre><?php echo htmlentities($row_page['text']); ?></pre>
    

    Or alternatively use CSS for a bit of extra flexibility:

    <div style="white-space: pre;"><?php echo htmlentities($row_page['text']); ?></div>
    

    Pre formatted whitespace has some drawbacks, for example you can’t have any newlines or indentation in your HTML file when you’re using pre, because the browser will render them. But when you really need to control how something is rendered it’s the best choice.

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

Sidebar

Related Questions

I just added printing capability to a web site using a style sheet (ie.
I have successfully implemented printing and print preview for my app using the PrintDocument,
Same problem was discussed earlier and I also knew that nothing, not also a
I have problem with getting username form windows system. I tried using getlogin function
I have created a WCF WebHttp Service using the following article as a guideline..
I am using the Sourcerer plugin to use PHP code inside my articles. I
I'm using SSRS 2008 to make something for label printing. I want to make
I've recently read this article on using printf and scanf in assembly: Meaning of
Sorry if this has been asked before - there's a question with a similar
I generated latex template using perl,and complied with MikTeX, its generating pdf. But I

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.