Home > Backend Development > PHP Tutorial > foreach引用问题

foreach引用问题

WBOY
Release: 2016-06-06 20:10:16
Original
961 people have browsed it

foreach($arr as $k=>&$v){} 到底是&v=元素值 还是$v=&name(元素值)

回复内容:

foreach($arr as $k=>&$v){} 到底是&v=元素值 还是$v=&name(元素值)

$v就是数组中元素的值,只不过不使用引用是foreach是拷贝元素值到$v里,所以修改$v时不会影响数组里的值,而使用引用时修改能直接体现在数组上。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template