compare textares

Discussion in 'PHP' started by roice, Nov 20, 2011.

  1. #1
    Hello,
    I want to create history for some text. I have textarea and when user submit the form I want to check if there were any changes in the text, and only if yes then save the new text.
    The problem is that I don't want that every ENTER (<br />) will be considered as new version. only if new letters was written than it will consider as new text.
    I'm using some text editor for my textarea field so every enter is new paragraph = "<p></p>"

    How should I deal with this issue?

    Thank you all in avanced,
    Roi.
     
    roice, Nov 20, 2011 IP
  2. Nikolas

    Nikolas Well-Known Member

    Messages:
    1,022
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    150
    #2
    You can do that with the strip_tags() function. This way you will only check the text without the tags.
     
    Nikolas, Nov 20, 2011 IP
  3. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #3
    Yes strip_tags will do the job, although you might want to save formatting changes to the text. You could try just str_replace() <p> and </p> tags in the comparison, then if the formatting is changed (i.e. bold, underline etc) it'll still be recognised as a change and updated.
     
    mfscripts, Nov 22, 2011 IP