Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:01:38+00:00 2026-06-18T06:01:38+00:00

First off, this is an exact duplicate of these four questions: Highlight the difference

  • 0

First off, this is an exact duplicate of these four questions:

  • Highlight the difference between two strings in PHP
  • JavaScript based diff utility
  • How to do text DIFF using PHP?
  • Calculate text diffs in PHP

It seems as though times have changed since these questions were first asked and I am wondering what is a good tool now-a-days for this sort of comparison? I have looked at (additionally to those questions):

  • https://github.com/nuxodin/diff_match_patch-php
  • http://pear.php.net/package/Text_Diff
  • https://github.com/paulgb/simplediff/blob/5bfe1d2a8f967c7901ace50f04ac2d9308ed3169/simplediff.php
  • http://www.raymondhill.net/finediff/viewdiff-ex.php

But all of the ones I get are either unmantained now or seem a little dodgy in that they are not used that much (and some even hint that they are not very performant) and the PEAR one worries me. I hate to install PEAR for one little module not only that but it seems like throwing a brick through my own window to install it for such a small module in comparison to PEAR in general not only that but the module has been superseded and placed on a different channel (dunno why?). I would use the PEAR version if it is my only choice but I want to use the upto date package.

Does anyone know of a well used and currently maintained or built in function (even if it is a PHP extension) text diff for PHP and/or JavaScript (JQuery as well)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:01:39+00:00Added an answer on June 18, 2026 at 6:01 am

    Ok so it has been a while.

    I actually decided to look around at what other people use and stumbled upon what Yii ( http://www.yiiframework.com ) uses.

    They actually use the PEAR module for their text_diff and they use it in its new form on the horde channel. It seems that text_diff is now a horde project but you can just as easily integrate a version of it into your application and that is what Yii does by default (it comes pre-bundled with a version of it).

    So I searched around a bit to find out how they used it and how to get into it and I came across:

    public function actionDiff()
    {
        Yii::import('gii.components.TextDiff');
    
        $model=$this->prepare();
        if(isset($_GET['id']) && isset($model->files[$_GET['id']]))
        {
            $file=$model->files[$_GET['id']];
            if(!in_array($file->type,array('php', 'txt','js','css')))
                $diff=false;
            elseif($file->operation===CCodeFile::OP_OVERWRITE)
                $diff=TextDiff::compare(file_get_contents($file->path), $file->content);
            else
                $diff='';
    
            $this->renderPartial('/common/diff',array(
                'file'=>$file,
                'diff'=>$diff,
            ));
        }
        else
            throw new CHttpException(404,'Unable to find the code you requested.');
    }
    

    In CCodeGenerator for their Gii module ( http://www.yiiframework.com/doc/api/1.1/CCodeGenerator/ ). The important part is where they actually hook into the PEAR module:

    $diff=TextDiff::compare(file_get_contents($file->path), $file->content);
    

    By reading in the contents of two files which produces a diffed output.

    Originally I did not want to use PEAR because of the bloat but this module is quite slim for a fully featured text_diff so I have decided to go with this. Not only that but, at the moment, it is the only text_diff module that has truly worked for me so I am keeping with the best, even if the best is quite memory hungry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, this is NOT a duplicate of: Turn a C string with NULL
First off, if there is an exact duplicate - I didn't find any so
First off, let me start by saying, I know this exact question has been
First off, I need to give a disclaimer: DO NOT RUN THIS JAVASCRIPT It
First off I use this code to make the navigation bar always stay fixed;
First off the html row looks like this: <tr class=evenColor> blahblah TheTextIneed blahblah and
First off I would like to say that this is my first post and
First off, I'm aware this is a bad practice and I have answered many
First off, I am running this on a dual core 2.66Ghz processor machine. I
First off - hello, this is my first Stack Overflow question so I'll try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.