Modified PHP loop