A generic way to split an array into pages, with optional callbacks to modify the structure of each page.