note 128741 added to language.types.array

From: Date: Tue, 18 Jul 2023 00:32:30 +0000
Subject: note 128741 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-220701@lists.php.net to get a copy of this message
This function makes (assoc.) array creation much easier: <?php function arr(...$array){ return $array; } ?> It allows for short syntax like: <?php $arr = arr(x: 1, y: 2, z: 3); ?> Instead of: <?php $arr = ["x" => 1, "y" => 2, "z" => 3]; // or $arr2 = array("x" => 1, "y" => 2, "z" => 3); ?> Sadly PHP 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/language.types.array.php Edit -- https://main.php.net/note/edit/128741 Del: integrated -- https://main.php.net/note/delete/128741/integrated Del: useless -- https://main.php.net/note/delete/128741/useless Del: bad code -- https://main.php.net/note/delete/128741/bad+code Del: spam -- https://main.php.net/note/delete/128741/spam Del: non-english -- https://main.php.net/note/delete/128741/non-english Del: in docs -- https://main.php.net/note/delete/128741/in+docs Del: other reasons-- https://main.php.net/note/delete/128741 Reject -- https://main.php.net/note/reject/128741 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220701) next »