Check out DiffChecker or TextMatch in terms of online apps. I'm not sure about the php part or if this will help you. If you need to automate it, I don't think it's possible with those tools. If you are looking for EXACT difference and not similarities etc, you can actually compares two documents with the newer versions of Word. But again, that's more for finding differences and not similarities.