Regularity results for a class of functionals with nonstandard growth