Description
The following code:
<?php
$criteria=[
"a",
"b",
];
var_dump($criteria);
foreach ($criteria as &$criterion) {
}
foreach ($criteria as /*&*/$criterion){
}
var_dump($criteria);
Resulted in this output:
array(2) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
}
array(2) {
[0]=>
string(1) "a"
[1]=>
&string(1) "a"
}
But I expected this output instead:
array(2) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
}
array(2) {
[0]=>
string(1) "a"
[1]=>
&string(1) "b"
}
PHP Version
PHP 8.5.3 (cli) (built: Feb 10 2026 18:44:09) (ZTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Built by The PHP Group
Zend Engine v4.5.3, Copyright (c) Zend Technologies
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies
Operating System
windows x64