How to shorten the input text

Discussion in 'PHP' started by x0x, Mar 16, 2010.

  1. #1
    Lets say an user submits some text that exceed the allowed number of characters. I don't want to deny the submission, rather I want it to only submit the first x amount of characters into the db. What's the function for that?
     
    x0x, Mar 16, 2010 IP
  2. mattinblack

    mattinblack Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Simple... string=substr ( $string , 0 , length ) you could also shorten it to 3 less and add '...' on the end to show it had been shortened.
     
    mattinblack, Mar 16, 2010 IP
  3. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thank you!
     
    x0x, Mar 16, 2010 IP
  4. miller23

    miller23 Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That works perfectly thanks too ;-)
     
    miller23, Mar 17, 2010 IP