Ugly problems often require ugly solutions. Solving an ugly problem in a pure manner is bloody hard.
I've never thought of PHP as more than a simple tool to solve problems.
I actually hate programming, but I love solving problems