Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

handling long words in php

Options
  • 18-03-2008 3:30pm
    #1
    Registered Users Posts: 648 ✭✭✭


    hi

    ive been looking for a function /way to handle long words entered by users in one of my applications.

    for example if a user enters
    ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

    then it will distort the page

    how do i introduce a space after ever 20th character if a string goes over a length of 20 ?


    thanks


Comments

  • Registered Users Posts: 2,472 ✭✭✭Sposs


    Javascript on the sign form would be your best bet.

    Would allow you to have max limit on the amount of characters.


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Apparently PHP has an in-built function:
    wordwrap($texttowrap, 40, "<br/>", 1);
    

    There is a CSS property, but it only worked in IE 7 for me. I don't know whether it's IE specific or what.
    word-wrap: break-word


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    Sposs wrote: »
    Javascript on the sign form would be your best bet.

    Would allow you to have max limit on the amount of characters.

    but i dont want to limit amount of characters - it will be a testarea that they can add a story to - its the word size im worries about .


    thanks


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Sposs wrote: »
    Javascript on the sign form would be your best bet.

    Would allow you to have max limit on the amount of characters.

    The amount of characters isn't the problem, it's the amount of continuous chracters without a space. If the PHP function doesn't work, you'd probably have to split the text into an array using a space or linebreak as the delimiter, and then iterate through the array and break up any strings.


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    eoin_s wrote: »
    Apparently PHP has an in-built function:
    wordwrap($texttowrap, 40, "<br/>", 1);
    

    There is a CSS property, but it only worked in IE 7 for me. I don't know whether it's IE specific or what.
    word-wrap: break-word


    wordwrap dont work - it only wraps text that has spaces - however u can see my text above has no spaces so this is a no go !
    thanks


  • Advertisement
  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Are you sure? This page says otherwise: http://uk3.php.net/wordwrap


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    eoin_s wrote: »
    Are you sure? This page says otherwise: http://uk3.php.net/wordwrap


    my bad in fact - i played with the params and yes indeed it works

    thanks lads


Advertisement