My website shows recommend pages for users. Right now, I suppose to send a query to get a URL addresses. It will be annoying to my server to get every single URL addresses. So, I would like to get 5 URL addresses from db and store them in to session as array.
array (
url[0] => google.com/1
url[1] => google.com/2
url[2] => google.com/3
url[3] => google.com/4
url[4] => google.com/5
)
It would like to store like this, and I would like to remove the first value after a user visits.
array (
url[0] => google.com/2
url[1] => google.com/3
url[2] => google.com/4
url[3] => google.com/5
)
It will be like this after first step.
array (
url[0] => google.com/5
)
At the end, there will be only one left in the session. After this, the server will send a query to get 5 different URL addresses. So, can you give me an idea how to set this up?
Take a look at array_shift
Example use:
output: