PHP - Echo removes additional spaces

Posted on 2009-12-31
Last Modified: 2013-12-13

I am giving a simple Echo command like this:

echo "Hello             Test"

But what gets displayed on the browser is

Hello Test

Basically its removing the extra white spaces in between the words 'Hello' & 'Test', is there something i can do to avoid this?

Thanks in advance


Question by:Vasan
    LVL 15

    Accepted Solution

    you have to replace spaces with html entity   :
    echo str_replace(' ', ' ', "Hello             Test");
    LVL 15

    Expert Comment


    You can try

    echo "Hello       test";

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now