I made a textbox labeled as “Page Numbers“.
The user may enter the page numbers in any sequence like 1, 3, 6.
I want to handle that if user entered 1, 4, 2, 6-8, 10. Then I should know that the user selected page number 1, 2, 4, 6, 7, 8, 10.
That means the user can also enter the range as well as comma separated numbers like we give the page numbers while printing documents.
The order number of pages can also be changed. For e.g. 5, 6, 4-8, 1. The numbers can be repeated but I need only the unique page numbers.
How I can do it in PHP? Thanks in Advance.
Here’s the plan of attack:
I’d make the set an assoc array and when I add a number to it I’d set it as the key. E.g.
Here’s the code: