|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-09-09 04:07 UTC] danielklein at airpost dot net
[2014-09-09 07:04 UTC] datibbaw@php.net
-Assigned To:
+Assigned To: datibbaw
[2014-09-09 10:05 UTC] datibbaw@php.net
[2014-09-09 10:05 UTC] datibbaw@php.net
-Status: Assigned
+Status: Closed
[2014-09-09 11:33 UTC] datibbaw@php.net
[2014-10-07 23:13 UTC] stas@php.net
[2014-10-07 23:24 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 05:00:01 2025 UTC |
Description: ------------ Unsetting the last item of an array that has a numeric key updates the last used index of the array but the previous information is used when copying this array. Changing unset() to array_pop() produces the expected behaviour. Test script: --------------- <?php // Output using xdebug $ary = array('zero', 'one', 'two'); //array_pop($ary); //array_pop($ary); unset($ary[1]); unset($ary[2]); $bry = $ary; $ary[] = 'three'; $bry[] = 'three'; var_dump($ary, $bry, $ary == $bry); ?> Expected result: ---------------- array (size=2) 0 => string 'zero' (length=4) 1 => string 'three' (length=5) array (size=2) 0 => string 'zero' (length=4) 3 => string 'three' (length=5) boolean false Actual result: -------------- array (size=2) 0 => string 'zero' (length=4) 1 => string 'three' (length=5) array (size=2) 0 => string 'zero' (length=4) 1 => string 'three' (length=5) boolean true