Re: HTML attribute / url safe wordwrap function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 4 Jan 2005 16:41:16 -0500, tg-php@xxxxxxxxxxxxxxxxxxxxxx
<tg-php@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> I don't know if I understand exactly what you're trying to do, but you might try the HTML tag <nobr></nobr> to get the HTML not to wrap the line.  See if that helps at all.
> 
> Good luck!
> 
> -TG
> 
> = = = Original message = = =
> 
> Howdy,
> 
> Yes, I've googled - and yes, I've searched the archives - but didn't
> find a solution for my problem. Here's the deal:
> 
> On a website ppl can react on articles and post messages. The content
> of a message is given to a function which parses it all, taking care
> of long "words" which could mess up the interface. Or actually - it
> does do that. It all wraps perfectly fine with the following lines of
> code:
> 
> <?php
>  $txt = 'website ppl can react on articles <a
> href="http://aspn.activestate.com/ASPN/docs/PHP/function.wordwrap.html";>wordwrap</a>';
>  $txt = preg_replace('#(<a.*>)((http|ftp|www).13)(.*)(.20)(</a>)#U',
> ' $1$2(...)$5$6 ', $txt);
>  $txt = preg_replace('/([\.\?\w\)\(\:\',!\-\=]30)/', '$1 ', $txt);
> ?>
> 
> Unfortunately, this also breaks the weblink address. So, some
> wordwrapping function that doesn't do that would be cool. So far, I
> haven't been able to find it or create it myself.
> 
> Somebody out there feels like giving it a shot?
> 
> Thanks,
> Wouter
> 

Nono .. this is actually quite the opposite ;). Thing is, I'm
expecting input like:

------------
Hi I aM sOmeBodY whO Is anNoyiNg
*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=
looK heRe: <a href="www.somewhere.com/some/long/path/exceeding/30/chars/and/even?more=notless">www.somewhere.com/some/long/path/exceeding/30/chars/and/even?more=notless</a>
------------

this long line of sequential characters causes the website interface
to stretch and thus needs to be "wrapped". Using php's wordwrap()
function won't do, cuz it will also wrap the URL so I'd be looking for
some function that only "adds some whitespace" to strings outside <
and > signs. Or: "not between < and >"

(input is shown as it eventually reaches the mentioned calls - I do
not actually allow thtml to be entered :P)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux