473,395 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

non breaking space in php

tolkienarda
316 100+
hi all

i writing a script where people can write atricles and the formating must save white space and break lines. the breakline problem has been fixed but about the whitespace problem.
do extra white spaces get deleted when i store them into a mysql database
example
there is a space at the begining of this line
and there are two spaces between those words

i can't seem to get them to display after i pull them from the database now i think i have a solution but it will almost kill me trying to do it.
i just recently learned how to use regular expressions and i was thinking about just searching for any series of spaces (more than one) and then replacing them with   but i think by the time i figure that out i will be nearly dead so if anyone has any ideas on what to do i would greatley appreiate it

eric
Mar 6 '07 #1
2 24937
bergy
89
Erik,

If you are displaying these articles as HTML the reason why you only get one space is because of the way HTML works - it has nothing to do with your database or PHP. HTML will only show 1 space between characters - so

Expand|Select|Wrap|Line Numbers
  1. <b>Here             Are           Spaces</b>
Would appear as:
Here Are Spaces

A quick fix in PHP would be to do this:

Expand|Select|Wrap|Line Numbers
  1. $myString = str_replace("  ", "&nbsp;&nbsp;", $articleText);
That is the quick and dirty way to do it, notice it looks for and replaces 2 spaces instead of just one. If we were to replace every space with &nbsp; you'd have what the browser would think was one big long word - meaning no word wrap and a huge horizontal scrollbar :)

Hope that helps!
Mar 6 '07 #2
tolkienarda
316 100+
ok thanks that makes my life way easier

eric
Mar 6 '07 #3

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

Similar topics

0
by: MarionEll | last post by:
XML Conference 2003 program now available…register with discounts now! IDEAlliance has just released the full program for XML 2003 scheduled December 7-12 at the Philadelphia Convention Center....
7
by: Philipp Lenssen | last post by:
I would like to know what others do to prevent line-breaks, using &nbsp; For example, the guidelines for the company have certain words (like "Model XY", where "Model" and "XY" shouldn't be...
1
by: Chris Sharman | last post by:
Writing a form, several questions have got a list of checkboxes, with associated descriptions (mostly one word), all on a line. Eg: Describe yourself: Fat Hairy Ugly Wears glasses. I want to...
87
by: Frances Del Rio | last post by:
is there a non-breaking hyphen in HTML?? for example, so a phone no. falls all on one line.. as in.. 1-800-444-5454... (and is not broken into two lines if phone no. occurs near end of a...
27
by: The Bicycling Guitarist | last post by:
Hi. I found the following when trying to learn if there is such a thing as a non-breaking hyphen. Apparently Unicode has a ‑ but that is not well-supported, especially in older browsers. Somebody...
3
by: Jorge Godoy | last post by:
Hi! Is there something I can do in PIL to restrict a line to a certain size and have it to break/wrap into a newline automatically? (Or by using some code, of course...) I'm trying to add...
4
by: m.shidoshi | last post by:
I was recently put in charge of heading up my company's website, and while I have a lot of experience on the design side of things, I'm still very new to the programming side. When I started, the...
4
by: Rubin | last post by:
1) I want to show a breaking hyphen in Mozilla 1.5.0.4 How do I do that? "Unicode standard annex #14", <http://www.unicode.org/reports/tr14/>, defines 4 breaking hyphens. <quote> Breaking...
5
by: plumba | last post by:
Ok, the title might not make it clear. I have a javascript code which generates an email. The page is on our corporate intranet so I know it will fire up the email ok. the code looks something...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.