I want to know number of items in a page and offset.
For example, I have 20 items in an array and per page 9 items.
Page 1, the number of items is 9 and offset is 0-8.
Page 2, the number of items is 9 and offset is 9-17.
Page 3, the number of items is 2 and offset is 18-19.
I guess I can do this
if pageNo * 9 < 20, means number of items is 9. else if pageNo * 9 > 20 like 27 > 20, number of items is 20 - 9 x (pageNo-1). But I would like to know if there's a shorter version.
Thanks