PHP String methods for Javascript