Doc #80685 [NEW]: array_merge - odd behaviour with string keys
| From: | raddi at gmx dot net | Date: | Fri, 29 Jan 2021 07:34:37 +0000 |
| Subject: | Doc #80685 [NEW]: array_merge - odd behaviour with string keys | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-18469@lists.php.net to get a copy of this message | ||
From: raddi at gmx dot net
Operating system: Ubuntu 20.04 / Windows
PHP version: Irrelevant
Package: Unknown/Other Function
Bug Type: Documentation Problem
Bug description:array_merge - odd behaviour with string keys
Description:
------------
Test-script below is expected to output the following (according to
documentation at https://www.php.net/manual/de/function.array-merge.php)
as the keys of the input-arrays are strings
Array
(
[54984941951919] => aa
[549849419519193] => bb
)
I get this result only on my old Raspberry running PHP
7.3.19-1~deb10u1.
On other servers (Windows witth 7.4.14; Docker with 7.4.14, 8.0.1,
7.3.19 and 7.3.26; even on an Ubuntu 20.04 with 7.3.19-1~deb10u1) the
result is
Array
(
[0] => aa
[1] => bb
)
with is for arrays with numeric keys.
Yes, the keys from Test-script can be converted to integer but was
defined as string key.
At least I expect a consistent behaviour on all PHP-versions and a hint
within the documentation about string keys beeing convertable to
integers.
I've found some older bugs (#25470, #18075, #13478, #54140) about this
behaviour with #54140 stating that in the manual I should read "Strings
containing valid integers will be cast to the integer type." but right
now it is not in the mentioned documentation anymore.
Test script:
---------------
$arra = array('54984941951919'=>'aa');
$arrb = array('549849419519193'=>'bb');
echo '<pre>';
print_r( array_merge($arra, $arrb) );
Expected result:
----------------
Array
(
[54984941951919] => aa
[549849419519193] => bb
)
Actual result:
--------------
Array
(
[0] => aa
[1] => bb
)
--
Edit bug report at https://bugs.php.net/bug.php?id=80685&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80685&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80685&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80685&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80685&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80685&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80685&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80685&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80685&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80685&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80685&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80685&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80685&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80685&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80685&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80685&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80685&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80685&r=mysqlcfg