From:             neel dot basu dot z at gmail dot com
Operating system: Debian Linux
PHP version:      5.2.3
PHP Bug Type:     Arrays related
Bug description:  array_map not working properly with string indexed array

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 bug report at http://bugs.php.net/?id=42382&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42382&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42382&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42382&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42382&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42382&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42382&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42382&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42382&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42382&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42382&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42382&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42382&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42382&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42382&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42382&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42382&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42382&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42382&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42382&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42382&r=mysqlcfg

Reply via email to