|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-08-04 19:14 UTC] gmblar+php at gmail dot com
Description:
------------
Add current array index as second argument to the callback of array_map
Test script:
---------------
<?php
$array = array(
'foo' => 23,
'bar' => 42
);
$result = array_map(function() {
return implode(':', func_get_args());
}, $array);
var_dump($result);
Expected result:
----------------
array(2) {
["foo"]=>
string(2) "23:foo"
["bar"]=>
string(2) "42:foo"
}
Actual result:
--------------
array(2) {
["foo"]=>
string(2) "23"
["bar"]=>
string(2) "42"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 20:00:01 2025 UTC |
Correct expected result: ---------------- array(2) { ["foo"]=> string(2) "23:foo" ["bar"]=> string(2) "42:bar" }