Req #70736 [Opn->Fbk]: Support to swap() function
| From: | cmb@php.net | Date: | Sat, 16 Jun 2018 13:46:44 +0000 |
| Subject: | Req #70736 [Opn->Fbk]: Support to swap() function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215754@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70736&edit=1
ID: 70736
Updated by: cmb@php.net
Reported by: david dot proweb at gmail dot com
Summary: Support to swap() function
-Status: Open
+Status: Feedback
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: Next Major Version
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> What's the problem with
list($a, $b) = [$b, $a]; ?
Good question!
Previous Comments:
------------------------------------------------------------------------
[2015-10-28 04:51:44] mail at jerrygrey dot me
Pull request: https://github.com/php/php-src/pull/1609
------------------------------------------------------------------------
[2015-10-28 04:51:25] marcio@php.net
What's the problem with list($a, $b) = [$b, $a]; ?
------------------------------------------------------------------------
[2015-10-19 04:12:06] david dot proweb at gmail dot com
Description:
------------
This function should swap two variables. Currently it can be done by code a swap function, like:
function swap(&$a, &$b) {
$tmp = $a;
$a = $b;
$b = $tmp;
}
I think that should be useful PHP do it alone, and simple to include it on code.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70736&edit=1