#31659 [NEW]: array_map to take non-array parameters and pass them to the callback function

From: Date: Sat, 22 Jan 2005 21:08:44 +0000
Subject: #31659 [NEW]: array_map to take non-array parameters and pass them to the callback function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-72679@lists.php.net to get a copy of this message
From: zizka at seznam dot cz Operating system: PHP version: 5.0.1 PHP Bug Type: Feature/Change Request Bug description: array_map to take non-array parameters and pass them to the callback function Description: ------------ array_map could take non-array parameters and pass them to the callback function in each step. Example: $a = explode(' ', 'XyX aXb sXs'); $a = array_map('str_replace', 'X','Y', $a); That would result in calling: str_replace('X','Y', $a[...]); and the result array would be like Array('YyY', 'aYb', 'sYs'); Now I have to define a callback function for many simple operations that could be done this way. Thanks, Ondra Zizka Reproduce code: --------------- $a = explode(' ', 'XyX aXb sXs'); $a = array_map('str_replace', 'X','Y', $a); print_r($a); Expected result: ---------------- Array( [0] => YyY [1] => aYb [2] => sYs ) Actual result: -------------- Warning: array_map() [function.array-map.htm]: Argument #2 should be an array in ... -- Edit bug report at http://bugs.php.net/?id=31659&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31659&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31659&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31659&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31659&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31659&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31659&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31659&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31659&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31659&r=support Expected behavior: http://bugs.php.net/fix.php?id=31659&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31659&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31659&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31659&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31659&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31659&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31659&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31659&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31659&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31659&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31659&r=mysqlcfg

« previous php.bugs (#72679) next »