Hello. Was hoping for some assistance.
Visitors can rank their top 5 favorite colors. Upon return, they can choose to re-rank these colors. I want to keep a site rank of favorite colors.
assume:
array $oldRank = "blue", "brown", "black", "orange", "red";
using a form, the same visitor enters these as his updated favorite colors:
array $newRank = "brown", "black", "pink", "purple", "green";
is there a function or method to report the difference in positions in an EFFICIENT way?
That is my question but if you would like more info on my self-admitted stupid thoughts, here's where my start is at right now.....
if (in_array($newRank[$i],$oldRank)) {......
to determine if each element in $newRank was an element in $oldRank. BUT, that presents two problems....
1) how do I determine the position of the element within $oldRank. key could be used but I don't think that would be efficient with the code I provided above.
2) how do I determine an element is in $oldRank but not $newRank without repeating the process but reversed?
Any help would be great and if I didn't explain clearly, please let me know and I'll try again. Thanks.