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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

handling long words in php

  • 18-03-2008 2:30pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 21,263 ✭✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 21,263 ✭✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


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


  • Registered Users, Registered Users 2 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