I found this snippet in a different question and answer, and it detects if a variable value is the same as the variable value in the previous loop.
$prevValue = NULL;
while(condition) {
if ($curValue == $prevValue) {
//do stuff
}
$prevValue = $curValue;
}
However what I want to do is to check if a variable value has been used before in the loop, but anywhere in the loop, so if the value happened 1 or 2 or 10 loops ago I want it to tell me if the variable value has come through the loop before.