|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-11-15 15:29 UTC] lbarnaud@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 11 19:00:02 2025 UTC |
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 )