private function diff($old, $new)
	{
		$maxlen = 0;
		// Go through each old line.
		foreach($old as $old_line => $old_value)
		{
			// Get the new lines that match the old line
			$new_lines = array_keys($new, $old_value);

			// Go through each new line number
			foreach($new_lines as $new_line)
			{
				$matrix[$old_line][$new_line] = isset($matrix[$old_line - 1][$new_line - 1]) ? $matrix[$old_line - 1][$new_line - 1] + 1 : 1;
				if($matrix[$old_line][$new_line] > $maxlen)
				{
					$maxlen = $matrix[$old_line][$new_line];
					$old_max = $old_line + 1 - $maxlen;
					$new_max = $new_line + 1 - $maxlen;
				}
			}
		}
		if($maxlen == 0)
		{
			return array(array('del'=>$old, 'ins'=>$new));
		}
		return array_merge(
				self::diff(array_slice($old, 0, $old_max), array_slice($new, 0, $new_max)),
				array_slice($new, $new_max, $maxlen),
				self::diff(array_slice($old, $old_max + $maxlen), array_slice($new, $new_max + $maxlen))
			);
	}
private function diff($old, $new)
	{
		$maxlen = 0;
		// Go through each old line.
		foreach($old as $old_line => $old_value)
		{
			// Get the new lines that match the old line
			$new_lines = array_keys($new, $old_value);

			// Go through each new line number
			foreach($new_lines as $new_line)
			{
				$matrix[$old_line][$new_line] = isset($matrix[$old_line - 1][$new_line - 1]) ? $matrix[$old_line - 1][$new_line - 1] + 1 : 1;
				if($matrix[$old_line][$new_line] > $maxlen)
				{
					$maxlen = $matrix[$old_line][$new_line];
					$old_max = $old_line + 1 - $maxlen;
					$new_max = $new_line + 1 - $maxlen;
				}
			}
		}
		if($maxlen == 0)
		{
			return array(array('del'=>$old, 'ins'=>$new));
		}
		return array_merge(
				self::diff(array_slice($old, 0, $old_max), array_slice($new, 0, $new_max)),
				array_slice($new, $new_max, $maxlen),
				self::diff(array_slice($old, $old_max + $maxlen), array_slice($new, $new_max + $maxlen))
			);
	}
private function diff ( $ old , $ new ) { $ maxlen = 0 ; // Go through each old line. foreach ( $ old as $ old_line => $ old_value ) { // Get the new lines that match the old line $ new_lines = array_keys ( $ new , $ old_value ) ; // Go through each new line number foreach ( $ new_lines as $ new_line ) { $ matrix [ $ old_line ] [ $ new_line ] = isset ( $ matrix [ $ old_line - 1 ] [ $ new_line - 1 ] ) ? $ matrix [ $ old_line - 1 ] [ $ new_line - 1 ] + 1 : 1 ; if ( $ matrix [ $ old_line ] [ $ new_line ] > $ maxlen ) { $ maxlen = $ matrix [ $ old_line ] [ $ new_line ] ; $ old_max = $ old_line + 1 - $ maxlen ; $ new_max = $ new_line + 1 - $ maxlen ; } } } if ( $ maxlen == 0 ) { return array ( array ( 'del' => $ old , 'ins' => $ new ) ) ; } return array_merge ( self :: diff ( array_slice ( $ old , 0 , $ old_max ) , array_slice ( $ new , 0 , $ new_max ) ) , array_slice ( $ new , $ new_max , $ maxlen ) , self :: diff ( array_slice ( $ old , $ old_max + $ maxlen ) , array_slice ( $ new , $ new_max + $ maxlen ) ) ) ; }
Diff function. Contributed by Dan Horrigan who again took it from
Paul Butler.

@author Paul Butler
@link http://github.com/paulgb/simplediff/blob/master/simplediff.php

@access private
@param string $old The old block of data
@param string $new The new block of data
Diff function . Contributed by Dan Horrigan who again took it from Paul Butler .