RE: Add element

From: Date: Mon, 29 Sep 2003 15:01:36 +0000
Subject: RE: Add element
Groups: php.general 
Request: Send a blank email to php-general+get-164250@lists.php.net to get a copy of this message
Warning ! Don't add one to your key ($j++) in this case. The "count()" method count ( :) ) return the number of existing keys in the $chk array. You'll make hole in your array if you do this : $arr[0] = "toto"; count($arr) => 1; $arr[1] = "tata"; count($arr) => 2; $arr[count[$arr]++] = "titi"; => $arr(0=>toto, 1=>tata, 3=>titi) (no 2=>) Prefer array_push($arr, ...) Cordialement, Jean-Philippe BENARD Consultant STERIA Infogérance (jean-philippe.benard-renexter@renault.com) Thanks for catching that Jean :| damn I hate monday mornings

« previous php.general (#164250) next »