By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,903 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,903 IT Pros & Developers. It's quick & easy.

How do you echo a long space

P: 1

I'm doing some PHP and MySQL, and have a very simple question.

How do you echo a long space? When I use echo " ": , it gets echo'd as only one space...

Using echo " "; echo " "; echo " "; doesn't help either.

Thanks in advance for answering :).


EDIT: what's funny is that every long space i typed here, got reduced to a single one as well... it's supposed to be: "____" that long..
May 14 '07 #1
Share this Question
Share on Google+
3 Replies

P: 3
This isn't a PHP problem, it's an HTML problem. By default the browsers eat away the whitespaces that come after the first whitespace. You can replace the whitespace by " " (without quotes) which the browser will recognize as a space.

You could also set the CSS property "whitespace" to "pre" for the containing element. That will stop the browser from eating whitespaces.
May 14 '07 #2

P: n/a
Display informat as u write

$new_string = str_replace(' ', '&nbsp;',$om);
echo nl2br($new_string);
<form method="post">

<textarea name="t"></textarea>
<input type="submit" name="ok">
Oct 17 '10 #3

P: n/a
I think the answer from @ Lick is on target, and I just wanted to add a suggestion .. to write a long space you should use

echo "&nbsp;&nbsp;";


echo"&nbsp;[space]&nbsp;"; to gain a longer space...

Oct 27 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.