note 125113 added to function.array-map
| From: | mail at markuszeller dot com | Date: | Fri, 12 Jun 2020 15:27:49 +0000 |
| Subject: | note 125113 added to function.array-map | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214760@lists.php.net to get a copy of this message | ||
Thanks to the new lambda function shorthand, you can compact the first example calculating cubic
values, which is much nicer to read.
You do not have to declare a function.
$a = [1, 2, 3, 4, 5];
$b = array_map(fn($n) => $n * $n * $n, $a);
print_r($b);
----
Server IP: 45.112.84.4
Probable Submitter: 103.51.166.36 (proxied: 2003:ed:8f19:7891:3194:a189:642a:2d06)
----
Manual Page -- http://php.net/manual/en/function.array-map.php
Edit -- https://master.php.net/note/edit/125113
Del: integrated -- https://master.php.net/note/delete/125113/integrated
Del: useless -- https://master.php.net/note/delete/125113/useless
Del: bad code -- https://master.php.net/note/delete/125113/bad+code
Del: spam -- https://master.php.net/note/delete/125113/spam
Del: non-english -- https://master.php.net/note/delete/125113/non-english
Del: in docs -- https://master.php.net/note/delete/125113/in+docs
Del: other reasons-- https://master.php.net/note/delete/125113
Reject -- https://master.php.net/note/reject/125113
Search -- https://master.php.net/manage/user-notes.php