Re: Proposal: Implement FR #7930 (list() constructor reference assignment)

From: Date: Wed, 23 Oct 2013 18:07:03 +0000
Subject: Re: Proposal: Implement FR #7930 (list() constructor reference assignment)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-69811@lists.php.net to get a copy of this message
On 23/10/2013 19:03, Matthew Leverton wrote:
Seems like a natural fit to me. Does it also work with the new foreach/list combo? foreach ($array as list(&$a, $b)) {}
Somehow I managed to forget to test that. Apparently, it does: ajf@raspberrypi ~/PHP/php-src $ sapi/cli/php -r '$arr = [[1,2],[3,4]]; foreach ($arr as list(&$a, $b)) $a = 7; var_dump($arr);' array(2) { [0]=> array(2) {
    [0]=>
    int(7)
    [1]=>
    int(2)
} [1]=> array(2) {
    [0]=>
    &int(7)
    [1]=>
    int(4)
} } I should probably add a test for this. -- Andrea Faulds http://ajf.me/

« previous php.internals (#69811) next »