signori sto letteralmente impazzendo !

obbiettivo dello script aggiungere in un'array di sessione un elemento numerico se eiste già settarlo a zero , mentre se esiste ed è settato a zero impostarlo ad 1.

ogni volta è un risultato diverso...non so più a che santi votarmi perchè #@@booom@@#@ sto cacchio di script funzioni.

Codice PHP:
session_start();

if(
is_array($_SESSION["arr_voti"])){
    echo(
"ARRAY OK
"
);
    
$t=(int)$_GET["idf"];
    if(
$t>0){
        if((!isset(
$_SESSION["arr_voti"][$t])) OR ($_SESSION["arr_voti"][$t]==0)){
            
$_SESSION["arr_voti"][$t]=1;
        }
        else{
            
$_SESSION["arr_voti"][$t]=0;
        }
    }
}
else{
    echo(
"ARRAY KO
"
);
    
$_SESSION["arr_voti"]=array();

vi prego aiutatemi è una situazione assurda.

se provo a fare un semplice accodamento del tipo $_SESSION["arr_voti"][]=$t; per vedere se va questo valore viene inserito sempre due volte...ma perchè ?