Simple text diff function
It looks fine. A few notes:

1, Use max instead of 

$length = count($old) &gt; count($new) ? count($old) : count($new);


2, Consider testing with newlines, tabs and maybe other whitespace characters.

3, http://en.wikipedia.org/wiki/Longest_common_subsequence could be useful if you want a better algorithm.

4, For removing HTML out of the function create a class which does it and delegate the calls to it. For example:

public interface Decorator {

    public function delete($input);

    public function insert($input);

    public function removeUnnecessaryMarkers($input);
}

public class HtmlDecorator {
    public function delete($input) {
        return "&lt;del&gt;{$input}&lt;/del&gt;";
    }
    public function insert($input) {
        return "&lt;ins&gt;{$input}&lt;/ins&gt;";
    }
    public function removeUnnecessaryMarkers($input) {
        return str_replace(array("&lt;/ins&gt; &lt;ins&gt;", "&lt;/del&gt; &lt;del&gt;"), " ", $input); 
    }
}




...
if(!isset($new[$i])) {
    $result .= $decorator-&gt;delete($old[$i]);
    continue;
}
...


(I haven't tested that this is a valid PHP syntax or not. Feel free to fix it.)