PHP Title Calculator and Helper functions