note 129023 added to language.types.array
| From: | TanxXan at main dot php dot net | Date: | Thu, 09 Nov 2023 13:11:45 +0000 |
| Subject: | note 129023 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220979@lists.php.net to get a copy of this message | ||
Alternative to associative arrays destructuring example above:
$source_array = ['foo' => 1, 'bar' => 2, 'baz' => 3];
// Assign the element at index 'baz' to the variable $three
// ['baz' => $three] = $source_array; original example
[, , $three] = array_values($source_array); //alternative example
echo $three; // prints 3
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 2001:448a:3042:9f28:de94:df3b:a7a8:c3f7)
----
Manual Page -- https://php.net/manual/en/language.types.array.php
Edit -- https://main.php.net/note/edit/129023
Del: integrated -- https://main.php.net/note/delete/129023/integrated
Del: useless -- https://main.php.net/note/delete/129023/useless
Del: bad code -- https://main.php.net/note/delete/129023/bad+code
Del: spam -- https://main.php.net/note/delete/129023/spam
Del: non-english -- https://main.php.net/note/delete/129023/non-english
Del: in docs -- https://main.php.net/note/delete/129023/in+docs
Del: other reasons-- https://main.php.net/note/delete/129023
Reject -- https://main.php.net/note/reject/129023
Search -- https://main.php.net/manage/user-notes.php