php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80538 SUGGESTION: Add reference to array destructuring of return values
Submitted: 2020-12-21 23:15 UTC Modified: 2021-08-18 01:42 UTC
From: toolmakersteve2 at shawstudio dot com Assigned: lufei (profile)
Status: Closed Package: Arrays related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2020-12-21 23:15 UTC] 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"];
}



Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-21 23:17 UTC] dharman@php.net
-Package: Documentation problem +Package: Arrays related
 [2020-12-21 23:20 UTC] 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:21 UTC] requinix@php.net
A simple adjustment would be to amend example #2 to also show destructuring as an alternative to list().
 [2020-12-22 11:53 UTC] 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
 [2021-08-18 01:39 UTC] lufei@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: lufei
 [2021-08-18 01:39 UTC] lufei@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.


 [2021-08-18 01:42 UTC] lufei@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

---

In Quick Fix, Fix committed is selected, and the Bug Type is Documentation problem, but it seems that the description is wrong.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 21 18:03:37 2021 UTC