For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > December 2005 > wrapping a long string at 80 chars









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author wrapping a long string at 80 chars
Greg Scharlemann

2005-12-18, 6:57 pm

Hey all

I'm working on creating a "send an email to a friend" page that
includes the link of a given search from a website. However, the url
of the website is really long and when displayed on the page it screws
up all of the formatting. Is there a way to force a wrap of the text?
Say each line is approx 80 characters.

I don't believe there is a simple HTML solution...wanted to see if
anyone on this forum had to do this previously and has some code to
share.

Thanks, Greg

Ewoud Dronkert

2005-12-18, 6:57 pm

Greg Scharlemann wrote:
> Is there a way to force a wrap of the text?


http://php.net/wordwrap

--
E. Dronkert
Greg Scharlemann

2005-12-18, 6:57 pm


Ewoud Dronkert wrote:
> Greg Scharlemann wrote:
>
> http://php.net/wordwrap


Sweet. Thanks.

Greg Scharlemann

2005-12-18, 6:57 pm

> > > Is there a way to force a wrap of the text?
>


The wordwrap function doesn't seem to work. It appears to wrap at the
next space in the string, but if I have a URL, there are no spaces and
thus no wrapping. Any other thoughts?

Kim André Akerĝ

2005-12-18, 6:57 pm

Greg Scharlemann wrote:

>
> The wordwrap function doesn't seem to work. It appears to wrap at the
> next space in the string, but if I have a URL, there are no spaces and
> thus no wrapping. Any other thoughts?


If you want to force a wrap on, say, an URL, just use the "cut"
parameter. See example 2 in the manual entry for wordwrap().

--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Ewoud Dronkert

2005-12-18, 6:57 pm

Greg Scharlemann wrote:
>
> The wordwrap function doesn't seem to work. It appears to wrap at the
> next space in the string, but if I have a URL, there are no spaces and
> thus no wrapping. Any other thoughts?


Yeah. Read it properly.

--
E. Dronkert
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com