Bug #68429 [NEW]: array_fill_keys function deletes repeated keys
| From: | jesushuertaarrabal at gmail dot com | Date: | Sun, 16 Nov 2014 18:20:28 +0000 |
| Subject: | Bug #68429 [NEW]: array_fill_keys function deletes repeated keys | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-188621@lists.php.net to get a copy of this message | ||
From: jesushuertaarrabal at gmail dot com
Operating system:
PHP version: 5.6.3
Package: Arrays related
Bug Type: Bug
Bug description:array_fill_keys function deletes repeated keys
Description:
------------
I was trying to associate values equals 1 for all the characters of a
simple word with repeated characters with the function array_fill_keys.
For any reason I found that some keys were erased for any reason after
using it like the example bellow.
Test script:
---------------
$word = 'metheor';
$arr = [];
echo strlen($word); //It shows the lenght of the word
for ($i = 0; $i < strlen($word); $i++){
$arr[] = $word[$i];
}
print_r($arr); //It shows the full word
print_r(array_fill_keys($arr, 0)); //It shows the word filled with 0's
but without repeated characters
Expected result:
----------------
array([m]=>1, [e]=>1, [t]=>1, [h]=>1, [e]=>1, [o]=>1, [r]=>1)
Actual result:
--------------
array([m]=>1, [e]=>1, [t]=>1, [h]=>1, [o]=>1, [r]=>1)
--
Edit bug report at https://bugs.php.net/bug.php?id=68429&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68429&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68429&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68429&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68429&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68429&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68429&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68429&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68429&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68429&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68429&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68429&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68429&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68429&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68429&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68429&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68429&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68429&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68429&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68429&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68429&r=mysqlcfg