Fix coding standards.
Use simpler and faster code.

substr_compare() is up to 2x slower than just substr(). Use a faster,
more common, and simpler to read variant of the same thing.