note 128738 added to function.array
| From: | Jordi at main dot php dot net | Date: | Fri, 14 Jul 2023 23:39:09 +0000 |
| Subject: | note 128738 added to function.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220697@lists.php.net to get a copy of this message | ||
This function makes (assoc.) array creation much easier:
function arr(...$array){ return $array; }
It allows for short syntax like:
$arr = arr(x: 1, y: 2, z: 3);
Instead of:
$arr = ["x" => 1, "y" => 2, "z" => 3];
or
$arr = array("x" => 1, "y" => 2, "z" => 3);
As you might have guessed, sadly even 8.2 doesn't support this named arguments in the
"array" function/language construct.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.168 (proxied: 89.99.238.18)
----
Manual Page -- https://php.net/manual/en/function.array.php
Edit -- https://main.php.net/note/edit/128738
Del: integrated -- https://main.php.net/note/delete/128738/integrated
Del: useless -- https://main.php.net/note/delete/128738/useless
Del: bad code -- https://main.php.net/note/delete/128738/bad+code
Del: spam -- https://main.php.net/note/delete/128738/spam
Del: non-english -- https://main.php.net/note/delete/128738/non-english
Del: in docs -- https://main.php.net/note/delete/128738/in+docs
Del: other reasons-- https://main.php.net/note/delete/128738
Reject -- https://main.php.net/note/reject/128738
Search -- https://main.php.net/manage/user-notes.php