If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Bandung, Indonesia
    Member #
    Guys, I've seen many examples of how we can compare two pieces of text with PHP and find out which areas have been added or removed. Can someone explain this to me? Or any code samples? I need this for a piece of web software I'm making.

    Many thanks!
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Cottage Grove, Minnesota
    Member #
    718 times
    Not really sure what your question means ...

    I usually look at this site:

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Boston, MA
    Member #
    205 times
    I know what you're talking about... this is something done in version control software to compare different versions of the same file.

    I've never seen code snippets for anything like this, but it would necessarily involve the use of arrays so you can move forward and backward line by line.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Atlanta, GA
    Member #
    1 times
    Well, if you have the permissions to invoke an external program, GNU diff is the standard program used for this on UNIX systems. Diffs (as they are called) are, indeed, relatively commonplace in the open source world and in version control systems. In websites, they're particularly common in wiki systems. That said, I'd advise looking at some wiki systems to see how they implement it. MediaWiki seems to have a fairly good diff implementation.

    Google gives you some options. There's also a PEAR module called Text_Diff. A quick discussion of a couple of the diff options for PHP is on this blog post. That one's a request for a PHP unified diff implementation for use with the PHPUnit unit testing library.

    More information on diffs at the wikipedia article on diff.

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 08:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: