Doc #80538 [Com]: SUGGESTION: Add reference to array destructuring of return values

From: Date: Wed, 27 Jan 2021 07:01:30 +0000
Subject: Doc #80538 [Com]: SUGGESTION: Add reference to array destructuring of return values
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18450@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80538&edit=1 ID: 80538 Comment by: denisebell142 at gmail dot com Reported by: toolmakersteve2 at shawstudio dot com Summary: SUGGESTION: Add reference to array destructuring of return values Status: Open Type: Documentation Problem Package: Arrays related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack The object and array literal expressions provide an easy way to create ad hoc packages of data. Destructuring can make working with an array return value more concise. References: Built-in objects. https://www.imessageapp.org/imessage-for-pc/ Previous Comments: ------------------------------------------------------------------------ [2020-12-22 11:53:37] cmb@php.net The following pull request has been associated: Patch Name: Add array destructuring documentation to array syntax section On GitHub: https://github.com/php/doc-en/pull/145 Patch: https://github.com/php/doc-en/pull/145.patch ------------------------------------------------------------------------ [2020-12-21 23:21:57] requinix@php.net A simple adjustment would be to amend example #2 to also show destructuring as an alternative to list(). ------------------------------------------------------------------------ [2020-12-21 23:20:42] dharman@php.net Thanks for the suggestion. PRs are welcome. If you can suggest an improvement to the https://github.com/php/doc-en we can take a look and update the documentation. PHP manual is a collaborative effort. ------------------------------------------------------------------------ [2020-12-21 23:15:29] toolmakersteve2 at shawstudio dot com Description: ------------ --- From manual page: https://php.net/functions.returning-values --- Would be good if this section mentioned use of [array destructuring syntax](https://www.php.net/manual/en/migration71.new-features.php#migration71.new-features.symmetric-array-destructuring) to access elements of a returned array, as a mechanism to simulate "multiple returned values". [$a, $b, $c] = myfunc(); where: function myfunc() { return ["first", "second", "third"]; } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80538&edit=1

« previous php.doc.bugs (#18450) next »