@@ -2930,7 +2930,9 @@ At least one of the elements of the *list-expression-list* must be non-empty.
29302930** Semantics**
29312931
29322932This intrinsic assigns one or more elements of the source array to the
2933- target variables. On success, it returns a copy of the source array. If the
2933+ target variables. On success, the target variable will be assigned to the
2934+ corresponding value in the source array. This can either be a reference
2935+ or a copy of the value depening if ` & ` preceeds the variable. If the
29342936source array is not an array or object implementing ` ArrayAccess ` no
29352937assignments are performed and the return value is ` NULL ` .
29362938
@@ -2980,6 +2982,12 @@ list($arr[1], $arr[0]) = [0, 1];
29802982list($arr2[], $arr2[]) = [0, 1];
29812983 // $arr2 is [0, 1]
29822984
2985+ $a = [1, 2];
2986+ list(& $one, $two) = $a;
2987+ // $a[0] is 1, $a[1] is 2
2988+ $one++;
2989+ // $a[0] is 2, $a[1] is 2
2990+
29832991list("one" => $one, "two" => $two) = ["one" => 1, "two" => 2];
29842992 // $one is 1, $two is 2
29852993list(
@@ -2990,6 +2998,13 @@ list(
29902998 "two" => 2,
29912999];
29923000 // $one is 1, $two is 2
3001+
3002+ $a = ['one' => 1, 'two' => 2];
3003+ list('one' => & $one, 'two' => $two) = $a;
3004+ // $a['one'] is 1, $a['two'] is 2
3005+ $one++;
3006+ // $a['one'] is 2, $a['two'] is 2
3007+
29933008list(list("x" => $x1, "y" => $y1), list("x" => $x2, "y" => $y2)) = [
29943009 ["x" => 1, "y" => 2],
29953010 ["x" => 3, "y" => 4]
0 commit comments