Next I have the system to do a history in a site, it saves the id of the page that the user visited, separating the ids by comma.
Would it be possible to limit the value to 30? example "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25.26,27,28,29,30 ".
And when that value exceeds it does it begin to update the older ones by replacing the values in descending order? example: "1,2,3 .... 29,53"
$id = $_COOKIE["id"];
$novoId = "$cont[id]";
if (!preg_match("/\b{$novoId}\b/", $id)) {
setcookie("id", $id .= "{$novoId},");
}
$historico = explode(",", $id);
$histanime = array_filter($historico, function($value) {
/* Retorna apenas os números inteiros */
return is_numeric($value);
});
$ids5 = implode(",", $histanime) ;