#42382 [Opn->Bgs]: array_map not working properly with string indexed array
| From: | johannes@php.net | Date: | Wed, 22 Aug 2007 15:39:10 +0000 |
| Subject: | #42382 [Opn->Bgs]: array_map not working properly with string indexed array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116481@lists.php.net to get a copy of this message | ||
ID: 42382
Updated by: johannes@php.net
Reported By: neel dot basu dot z at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Debian Linux
PHP Version: 5.2.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
Previous Comments:
------------------------------------------------------------------------
[2007-08-22 15:21:07] neel dot basu dot z at gmail dot com
Description:
------------
If string indexed array is given to array_map it returns numerically
indexed array after applying the callback.
I am using PHP 5.2.1 on Debian Linux.
Reproduce code:
---------------
<?php
$r = array('one' => 'HeLlO', 'two' => 'Hi');
print_r($r);//Orgiginal array
$r = array_map('tst_it', $r, array(false));
function tst_it($r, $bool = false){
if($bool){return strtoupper($r);}
else{return strtolower($r);}
}
print_r($r);//Array after array_map
?>
Expected result:
----------------
Array
(
[one] => HeLlO
[two] => Hi
)
Array
(
[one] => hello
[two] => hi
)
Actual result:
--------------
Array
(
[one] => HeLlO
[two] => Hi
)
Array
(
[0] => hello
[1] => hi
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42382&edit=1