Page 1 of 1

spacing to align lines..

Posted: Tue Sep 16, 2003 11:28 pm
by Drachlen
You know how in books, or some news-posting systems on webpages, you'll see this double-spacing or sometimes triple-space inbetween words to align the end of lines? It aligns all the cols perfectly.. Well im curious as to how some php scripts do this... I've attempted to grab the string length of each line, and then add a space next to other spaces until the line is the length i set, but i am not able to just update 1 space. So has anyone done anything like this and like to shed some light? If i could figure out a way to limit str_replace to only 1 replace then i might be able to do it..

Posted: Wed Sep 17, 2003 1:34 am
by SantaGhost
i think your best guess on this is css (http://www.w3schools.com/css)

Re: spacing to align lines..

Posted: Wed Sep 17, 2003 2:27 am
by Heavy
CSS:

Code: Select all

<div style="text-align:justify">This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?This may be what you are looking for?</div>
Try that.
It is not PHP. This is all client side. In fact PHP can not deal with this, as the impression on the user is totally dependent on the font faces and font sizes that are used aswell as what browser renders the output.

I believe it is the style="text-align:justify" part you are interested of.

Posted: Wed Sep 17, 2003 5:42 am
by JAM
You can also use wordwrap() to automaticly wrap strings after a certain num of chars.

Posted: Wed Sep 17, 2003 9:28 am
by Drachlen
Thanks heavy :D