PHP reference traverses the array, why is the output of the last element of the array preceded by a &

topic description

traversing the array with foreach and using the & reference assignment, I can"t understand why the last value of the array element is preceded by a &

related codes

/ / Please paste the code text below (please do not replace the code with pictures)
$arr=array (1meme 2Jing 3Jing 4);
foreach ($arr as & $value) {

$value=$value*2;

}
var_dump ($arr);
? >

the running result is as follows

clipboard.png

Php
May.23,2022

because your foreach adds the & reference symbol, this variable is still valid at the end of the loop (foreach does not isolate scope) and is a reference variable

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b41672-2b2d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b41672-2b2d2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?