My old requirement was to maintain a list of 5 recently clicked product ids so that the last clicked was first in the list.
I did this by storing a semicolon delimited string, splitting it into an array, removing the number to be added from the array (if it existed), then adding it to the front of the list. Creating a new array from a split function, then saving the proper number of elements. This would ensure that if my new product was already clicked, it would move to the front.
5;3;6;1;7 and clicking on 7 would yelid 7;3;6;1
I just found out that I need to do the same thing, but maintain the list of 5 products per a list of 5 companines.
clicking on company2 and product 13 would give me company2=10
If I already have 5 companines and I click on a new one, add it to the top, and get rid of the last.
If the company already exists, add it to the beginning of the list, and add the product to the beginning of that list.
I have no idea how to tackle this.