I have an array of users and I need to loop between them. It will work like this, every time someone makes a request on the page, I need the next user to be saved in the database of the one that was previously chosen.
This is my array, which I get from registered users, this array can change.
array(
(int) 1 => 'Joao',
(int) 6 => 'Pedro',
(int) 7 => 'Luiz',
(int) 9 => 'Vinicius'
)
That is, if in the previous request the one that was chosen was the Pedro
(I get the id that was previously saved), I need to next save the id
luiz in the DB, and so on ...
My question is, how to "walk" with the values of this array based on the last value registered?