mirror of
https://github.com/php/php-src.git
synced 2025-01-17 01:04:35 +08:00
33 lines
352 B
PHP
33 lines
352 B
PHP
--TEST--
|
|
foreach() with references
|
|
--FILE--
|
|
<?php
|
|
|
|
$arr = array(1 => "one", 2 => "two", 3 => "three");
|
|
|
|
foreach($arr as $key => $val) {
|
|
$val = $key;
|
|
}
|
|
|
|
print_r($arr);
|
|
|
|
foreach($arr as $key => &$val) {
|
|
$val = $key;
|
|
}
|
|
|
|
print_r($arr);
|
|
|
|
--EXPECT--
|
|
Array
|
|
(
|
|
[1] => one
|
|
[2] => two
|
|
[3] => three
|
|
)
|
|
Array
|
|
(
|
|
[1] => 1
|
|
[2] => 2
|
|
[3] => 3
|
|
)
|