[php-src] Issue #12335: foreach bug
| From: | 143981 | Date: | Sun, 01 Oct 2023 08:41:46 +0000 |
| Subject: | [php-src] Issue #12335: foreach bug | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245469@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12335
Author: 143981
### Description
The following code:
```php
<?php
$ar = array(
1 => 1,
2 => 2
);
$p = 0;
foreach($ar as &$p) {
echo $p."\n";
}
$p = 0;
foreach($ar as $p) {
echo $p."\n";
}
```
Resulted in this output:
```
1
2
1
1
```
But I expected this output instead:
```
1
2
1
2
```
### PHP Version
8.2.11
### Operating System
Gentoo