The role of environment on the formation of early-type galaxies