bestbuildpc: Forums
 

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to add extra whitespace in PHP?
 
 
Post new topic   Reply to topic    bestbuildpc Forum Index -> RavenNuke -> General and Questions
View previous topic :: View next topic  
Author Message
bestbuildpc
Site Admin
Site Admin


Joined: Jun 30, 2012
Posts: 169
Location: NL

PostPosted: Wed May 14, 2014 16:44    Post subject: How to add extra whitespace in PHP? Reply with quote

Some examples:

Code:
str_repeat(' ', 5); // adds 5 spaces


and

Code:
Actually PHP generates HTML output for a web-site. When displaying HTML, the browser collapses all whitespace in text into a single space. Sometimes, between tags, it even collapses whitespace to nothing. In order to persuade the browser to display whitespace, you need to include special tags like &nbsp; or <br/> in your HTML to add non-breaking whitespace or new lines, respectively.



To render more than one whitespace on most web browsers use &nbsp; instead of normal white spaces.


Code:
echo "<p>Hello &nbsp;&nbsp;&nbsp; punt"; // This will render as Hello   Punt (with 4 white spaces)

echo "<p> Hello       punt"; // This will render as Hello punt (with one space)


For showing data in raw format (with exact number of spaces and "enters") use HTML <pre> tag.

Code:
echo "<pre>Hello        punt</pre>"; //Will render exactly as written here (8 white spaces)
  
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    bestbuildpc Forum Index -> RavenNuke -> General and Questions All times are GMT + 2 Hours
 
 Page 1 of 1

 

Jump to:   
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001-2008 phpBB Group
 
Forums ©