ID: 46576 Updated by: [EMAIL PROTECTED] Reported By: geo at vzemibg dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: CentOS PHP Version: 5.2.6 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Try using $testarr = array_values($testarr) to remove the holes between the keys. Previous Comments: ------------------------------------------------------------------------ [2008-11-14 17:56:03] geo at vzemibg dot com Description: ------------ I am submitting what in my view is uncorrect behaviour of the [] operator for arrays. It is a special case when the last element of the array is removed with unset() and then a new element is added using the arrname[] = xxxx syntax. Reproduce code: --------------- $teststring = "let's test this"; $testarr = explode(' ', $teststring); print_r($testarr);echo "<br />"; unset($testarr[2]); print_r($testarr);echo "<br />"; $testarr[] = 'new'; print_r($testarr); Expected result: ---------------- Array ( [0] => let's [1] => test [2] => this ) Array ( [0] => let's [1] => test ) Array ( [0] => let's [1] => test [2] => new ) Actual result: -------------- Array ( [0] => let's [1] => test [2] => this ) Array ( [0] => let's [1] => test ) Array ( [0] => let's [1] => test [3] => new ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46576&edit=1
