This is a discussion on RE: Add element within the PHP General forums, part of the PHP Programming Forums category; Warning ! Don't add one to your key ($j++) in this case. The "count()" method count ( :) ) return the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|