|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-08-28 13:05 UTC] tin dot legall at wishgroupe dot com
Description: ------------ Take example #2 at the following address and switch $double and $number declarations http://php.net/manual/en/language.types.callable.php Expected result: ---------------- 2 4 6 8 10 Actual result: -------------- 1 2 3 4 5 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
Here is the code example that illustrates the problem: <?php // This is our range of numbers $numbers = range(1, 5); // Our closure $double = function($a) { return $a * 2; }; // Use the closure as a callback here to // double the size of each element in our // range $new_numbers = array_map($double, $numbers); print implode(' ', $new_numbers); ?> Expected result: ---------------- 2 4 6 8 10 Actual result: -------------- 1 2 3 4 5