/** * Compare two texts and show the differences report * @param string $a * @param string $b * @return string */ public static function diffTexts($a, $b) { Yii::import('ext.TextDiff.*'); Yii::import('ext.TextDiff.Text.*'); $diffObj = new TextDiff(); // For some reason without the space this does not work. // Have no clue why but at least the space thing solves it $diffObj->getDiff(' ' . $a . ' ', ' ' . $b . ' '); return $diffObj->myOutput ? $diffObj->myOutput : Yii::t('global', 'Error trying to show the differences.'); }