Ciao,
ho una funzione che deve controllare dei dati passati da un form...
Stranamente funziona solo se la variabile è vuota oppure e corretta, ma nel controllo se è troppo corta o troppo lunga non assegna all'array errore i corretti valori:

Codice PHP:
private function validaDati(){
        
$this->dati["Errori"] = false;
            
// CONTROLLO IL NOME
            
if($this->dati["Nome"] == ""){
                
$this->dati["Errori"] = true;
                
$this->dati["Nome"]["Valore"] = $this->dati["Nome"];
                
$this->dati["Nome"]["Errore"] = true;
                
$this->dati["Nome"]["ErroreDesc"] = "Non hai inserito il nome!";
            } else if(
strlen($this->dati["Nome"])<= 2){
                
$this->dati["Errori"] = true;
                
$this->dati["Nome"]["Valore"] = $this->dati["Nome"];
                
$this->dati["Nome"]["Errore"] = true;
                
$this->dati["Nome"]["ErroreDesc"] = "Nome troppo corto!";
            } else if(
strlen($this->dati["Nome"])>= 15){
                
$this->dati["Errori"] = true;
                
$this->dati["Nome"]["Valore"] = $this->dati["Nome"];
                
$this->dati["Nome"]["Errore"] = true;
                
$this->dati["Nome"]["ErroreDesc"] = "Nome troppo lungo!";
            } else {
                
$this->dati["Nome"]["Valore"] = $this->dati["Nome"];
            }
    return 
$this->dati;
    } 
Se io inserisco a nel form lui mi restituisce questo:
array(4) { ["Nome"]=> string(1) "N" ["Cognome"]=> string(0) "" ["Mail"]=> string(0) "" ["Errori"]=> bool(true) }

Come mai?