A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearHow to do text DIFF using PHP? - page 1
User InfoPosts
How to do text DIFF using PHP?#1
What is the best way to do this for PHP? Is there any PHP function that can do this, considering the column content could be very large?

If PHP function is not available, what shell utility can I call?

thanks

posted date: 2009-04-09 21:09:00


Re: How to do text DIFF using PHP?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-09 21:09:01


Re: How to do text DIFF using PHP?#3
The usual process is to store each distinct revision and calculate the diff when the user wants to view it, perhaps caching that output if the process is expensive.You could store a base revision, and then have a set of diffs which can be applied to obtain previous versions.In either case, there(s a concession to be made; the first option makes retrieving specific versions inexpensive, at the cost of a little more processing required for diffing; the second makes diff viewing cheap, but at the cost of potentially expensive incremental patching to obtain a specific version.

posted date: 2009-04-09 21:11:00


Re: How to do text DIFF using PHP?#4
there aren(t any built in diff functions in PHP. but, hooray for PEAR: Text_Diff (never used it tough, but in PEAR i trust).and there(s even a PECL package, xdiffhint: pear classes are pure php, pecl packages are modules. normally, modules are faster than classes, but it also depends on the functionality. you just have to test and evaluate.for storing: i(d store the plain text, not the diffs. space is cheap, many databases (e.g. mysql) support data compression (or you could de/compress in php), but if you store the plaintext, you(re independent of the diff algorithm and can change it later if needed. if you need speed, you could store both the plaintexts AND the diffs.

posted date: 2009-04-09 22:29:00


Re: How to do text DIFF using PHP?#5
+1: I've used Text_Diff in the past and it does the job.

posted date: 2009-04-09 22:36:00


Re: How to do text DIFF using PHP?#6
If the content is very large and the changes are only minor ones, you may consider to go for a "reverse delta" approach: only the latest version of the text is stored in full format, and the previous vesion is a diff from the latest version to the previous. It would spare a lot of storage space, but comparing two versions where the number of modifications is large, the cost of the process could be considerable. After all, it is always a tradeoff between storage space and processing requirements.If you can(t or don(t want to user PEAR and PECL, you still can use the diff utility called by exec. I(d go for a standard diff format for sure, and never develop an own one.

posted date: 2009-04-09 22:41:00


Re: How to do text DIFF using PHP?#7
@PaoloBergantino Can you give a code example?

posted date: 2013-01-20 00:42:00


Re: How to do text DIFF using PHP?#8
You can see here that Text_Diff can use xdiff. @hitautodestruct you can find examples at: pear.php.net/manual/en/…

posted date: 2013-02-09 23:35:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.