Excerpt filter is adding ” in incorrect place

It happens because using explode() to parse HTML is at least equally evil as trying to do it with regex.

To “fix” it, the quick ’n dirty way, you could add the following preg_replace() after the implode() line:

$wpse0001_excerpt = implode( '</p>', $tmp_to_add ).'</p>';
$wpse0001_excerpt = preg_replace( '/<\/p>\s*<\/p>/', '</p>', $wpse0001_excerpt );

Using something like PHP’s DOM extension would be cleaner. This is no longer WordPress related, though.