当前位置:网站首页>Usage of PHP interview questions foreach ($arr as $value) and foreach ($arr as $value)

Usage of PHP interview questions foreach ($arr as $value) and foreach ($arr as $value)

2022-07-07 18:24:00 Southern Song Dynasty x

Interview questions :

<?php
$arr = [0,1,2,3,4];

foreach ($arr as &$val) {
    
	// nothing
}
foreach ($arr as $val) {
    
	// nothing
}
//  What will be output 
var_export($arr);
/********* **  answer :** *********/
array (
  0 => 1,
  1 => 2,
  2 => 3,
  3 => 8,
  4 => 'a',
  5 => 'a',
)

For detailed explanation, please refer to :
https://blog.csdn.net/smxdgf/article/details/105370166

原网站

版权声明
本文为[Southern Song Dynasty x]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071614054663.html