Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts

    Auto insert 'space' on long words

    Hi.

    I want to create a function that automatically inserts spaces in long words/strings. Some people enjoy doing "@@@@@@@@@@@@@@@@@...[etc]" just to mess around - and it hops out of the webpage's layout and continues on and on.

    Although I have put overflow: hidden; on my site, however I'd like to automatically insert a space in a string that's 20 characters or more without any spaces.

    So @@@[20 times] -insert space here- @@@@[20 more] -insert space here-.
    That way the text would just continue but get a line break on the page.

    Thanks.
    Last edited by [vengeance]; 10-10-2009 at 10:54 AM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Use wordwrap function with explicit cut:
    PHP Code:
    $sLongString '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@......';
    $sBrokenString wordwrap($sLongString20' 'true); 
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    [vengeance] (10-10-2009)

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by Fou-Lu View Post
    Use wordwrap function with explicit cut:
    PHP Code:
    $sLongString '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@......';
    $sBrokenString wordwrap($sLongString20' 'true); 
    Wow - that function is so simple, yet efficient! I thought I'd have to make a similar function myself to get what I wanted to achieve.

    Worked, thanks!

  • #4
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    A while back I offered a means to wrap only long words, regardless of the length of the line. It may be of some help to you as well.

    http://www.codingforums.com/showpost...68&postcount=7
    Last edited by kbluhm; 10-10-2009 at 12:45 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •