php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55366 keys lost when using substr_replace replace an array
Submitted: 2011-08-05 02:33 UTC Modified: 2011-08-29 20:39 UTC
Votes:7
Avg. Score:3.3 ± 0.7
Reproduced:0 of 0 (0.0%)
From: gorshang at gmail dot com Assigned: arpad (profile)
Status: Closed Package: Strings related
PHP Version: 5.3.6 OS: win7
Private report: No CVE-ID: None
 [2011-08-05 02:33 UTC] gorshang at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.substr-replace%23Changelog
---
My version is 5.3.5.
But the keys lost when replace an array.
I wan't write more, but I can't. 
Oh, my poor English.
I'm Chinese.
Tank you.


Test script:
---------------
<?php

$arr = array('abc'=>'llsskdkk','def'=>'llsskjkkdd');
$newarr = substr_replace($arr, 'zzz', 0, -2);

print_r($newarr);

?>

Expected result:
----------------
Array
(
    [abc] => zzzkk
    [def] => zzzdd
)

Actual result:
--------------
Array
(
    [0] => zzzkk
    [1] => zzzdd
)

Patches

php-trunk-substr_replace-array-keys (last revision 2011-08-05 10:20 UTC by arpad@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-05 02:51 UTC] gorshang at gmail dot com
-Summary: keys lost when replace an array +Summary: keys lost when using substr_replace replace an array
 [2011-08-05 02:51 UTC] gorshang at gmail dot com
keys lost when using substr_replace replace an array
 [2011-08-05 09:45 UTC] arpad@php.net
The following patch has been added/updated:

Patch Name: php-trunk-substr_replace-array-keys
Revision:   1312537507
URL:        https://bugs.php.net/patch-display.php?bug=55366&patch=php-trunk-substr_replace-array-keys&revision=1312537507
 [2011-08-05 10:20 UTC] arpad@php.net
The following patch has been added/updated:

Patch Name: php-trunk-substr_replace-array-keys
Revision:   1312539652
URL:        https://bugs.php.net/patch-display.php?bug=55366&patch=php-trunk-substr_replace-array-keys&revision=1312539652
 [2011-08-05 23:41 UTC] felipe@php.net
-Package: *General Issues +Package: Strings related
 [2011-08-29 20:38 UTC] arpad@php.net
Automatic comment from SVN on behalf of arpad
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=315740
Log: Fixed bug #55366: keys lost when using substr_replace an array
 [2011-08-29 20:39 UTC] arpad@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: arpad
 [2011-08-29 20:39 UTC] arpad@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2011-08-29 21:35 UTC] arpad@php.net
Automatic comment from SVN on behalf of arpad
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=315746
Log: Fixed bug #55366: keys lost when using substr_replace an array
 [2012-04-18 09:49 UTC] laruence@php.net
Automatic comment on behalf of arpad
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a912bd3c23ec6a5609cc3adc2ce69b467c34921c
Log: Fixed bug #55366: keys lost when using substr_replace an array
 [2012-07-24 23:40 UTC] rasmus@php.net
Automatic comment on behalf of arpad
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a912bd3c23ec6a5609cc3adc2ce69b467c34921c
Log: Fixed bug #55366: keys lost when using substr_replace an array
 [2013-11-17 09:36 UTC] laruence@php.net
Automatic comment on behalf of arpad
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a912bd3c23ec6a5609cc3adc2ce69b467c34921c
Log: Fixed bug #55366: keys lost when using substr_replace an array
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC