After several hours of trying, I finally got this fixed.
The problem wasn’t in the php code, like I kept trying to figure out. The posts were, for some odd reason, adding div tags into themselves. Probably due to the fact that I was copy/pasting the text into it and it brought with it formatting.
At least it was an easy fix, even if it was frustrating. ??