Bug #79364 [NEW]: When copy empty array, next key is unspecified.
| From: | yuubiseiharukana at gmail dot com | Date: | Tue, 10 Mar 2020 14:38:28 +0000 |
| Subject: | Bug #79364 [NEW]: When copy empty array, next key is unspecified. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-226006@lists.php.net to get a copy of this message | ||
From: yuubiseiharukana at gmail dot com
Operating system: Any
PHP version: 7.4.3
Package: Arrays related
Bug Type: Bug
Bug description:When copy empty array, next key is unspecified.
Description:
------------
Copy array.
When arrays next index=2 and max key=2, next key is both 2.
When arrays next index=2 and max key=1, next key is both 2.
When arrays next index=2 and max key=0, next key is 0 or 2.
Test script:
---------------
https://3v4l.org/TYc10
$a = [1, 2];
unset($a[1], $a[0]);
$b = $a;
$a[] = 3;
$b[] = 4;
var_dump($a, $b); // $a = [0=>3] $b = [2=>4]
When increase variables, only the last one take over key.
Expected result:
----------------
Always same key whth $a and $b.
Actual result:
--------------
Same key when array is not empty.
Not same key when array is empty.
--
Edit bug report at https://bugs.php.net/bug.php?id=79364&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79364&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79364&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79364&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79364&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79364&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79364&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79364&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79364&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79364&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79364&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79364&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79364&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79364&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79364&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79364&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79364&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79364&r=mysqlcfg