Why do I get a different output with $key++
and $key+1
?
What should I do to refer to the next element in the loop using foreach
?
foreach($diff as $key=>$val) {
if(in_array($diff[$key],$common) && in_array($diff[$key+1],$common)) {}
if(in_array($diff[$key],$common) && in_array($diff[$key++],$common)) {}
}