First of all i think, you need to obtain array length , then if length > or equal to 5, remove first element , and add element to the end of array.
if (!in_array($articleid, $lastviewedarticles)){
$count = count($lastviewedarticles);
if($count>=5)
array_shift($lastviewedarticles);
$lastviewedarticles[] = $articleid;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…