unset array element

From: Date: Tue, 13 May 2003 22:40:25 +0000
Subject: unset array element
Groups: php.general 
Request: Send a blank email to php-general+get-147503@lists.php.net to get a copy of this message
Hi all, I have a problem to unset an array element in an object example: <?php class teste { var $teste; var $teste1; var $arr; function teste($wparam,$wparam2) { $this->teste = $wparam; $this->teste1 = $wparam2; $this->arr = array(); } function arr_add($wchave,$valor) { $this->$wchave = array($valor, 0); } function arr_rem($wchave) { unset($this->arr[$wchave]); // <----THERE IS THE PROBLEM, THIS IS NOT WORKING WITH ME } function __get($prop_name, &$prop_value) { if (isset($this->arr[$prop_name])) { $prop_value = $this->arr[$prop_name][0]; return true; } else { return false; } } function __set($prop_name, $prop_value) { if (is_array($prop_value)==1) { $this->arr[$prop_name] = $prop_value; } else { $this->arr[$prop_name][0] = $prop_value; } return true; } } overload('teste'); $avar = new teste("teste","test1"); $avar->arr_add("primeiro",1); $avar->arr_add("segundo",2); $avar->arr_add("terceiro",3); $avar->arr_add("quarto",4); $avar->arr_add("quinto",5); $avar->arr_rem("quinto"); // WHEN I CALL ARR_REM() PHP CLOSE WITH NO ERROR DEFINED $avar->segundo = "ola"; $avar->terceiro = 3; $avar->quarto = 4; $avar->quarto = $avar1->segundo; ?> Can any one help me? Bests,

« previous php.general (#147503) next »