Tracking changes in user input (string).

Discussion in 'PHP' started by metallic07039, Jun 10, 2007.

  1. #1
    I am programming a template management system. In my script users have the ability to large blocks of text. I want to track the changes they make. For example:

    Body of text stored in the database:

    Fish are aquatic vertebrates that are typically cold-blooded, covered with scales, and equipped with two sets of paired fins and several unpaired fins. Fish are abundant in the sea and in fresh water, with species being known from mountain streams (e.g., char and gudgeon) as well as in the deepest depths of the ocean (e.g., gulpers and anglerfish).

    User edits the above paragraph to (I have bolded what is changed):

    Tigers are aquatic vertebrates that are typically warm-blooded, covered with scales, and equipped with two sets of paired fins and one unpaired fins. Fish are abundant in the sea and in fresh water, with species being known from plain streams (e.g., char and gudgeon) as well as in the deepest depths of the ocean (e.g., gulpers).

    PHP would output:
    - Changed "Fish" to "Tigers".
    - Changed "cold-blooded" to "warm-blooded".
    - Changed "mountain" to "plain".
    - Deleted "and anglerfish".

    --------

    What is the easiest way to do this?
     
    metallic07039, Jun 10, 2007 IP
  2. HypertextFever

    HypertextFever Peon

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    HypertextFever, Jun 10, 2007 IP
  3. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #3
    I don't know of an automatic way to do what you want.
    I would probably break the text into words (explode by spaces) and loop through the whole original while comparing it to the new text - word by word. It should work...
     
    NoamBarz, Jun 10, 2007 IP
  4. metallic07039

    metallic07039 Peon

    Messages:
    272
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    metallic07039, Jun 10, 2007 IP