Well, what you get is a page order that will end on page 1.
And then, when the respondent clicks on "next" on page 1, page 2 will be displayed, because this is the next page. So you will see all pages 2..6, again.
Try to put the PHP code on page '1' and remove this line:
$pages[] = '1';
And instead add the page to display after (!) page 6, e.g. '7'
$pages[] = '7';