<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_19255"> foreach 数组 值修改 <br> <div class="blockcode"> <div id="code_ufQ"><ol> <li><?php<li>/**<li> * 注意foreach取值的差异<li> */<li>$arr = array(1,2,3,4);<li><li>echo "foreach遍历数组1:<br>";</li> <li>foreach($arr as $val) {</li> <li> $val = $val*2;</li> <li>}</li> <li> <li>var_dump($arr);</li> <li> <li>echo "<br />foreach遍历数组2:<br>";</li> <li>foreach($arr as &$val) {</li> <li> $val = $val*2;</li> <li>}</li> <li> <li>var_dump($arr);</li> <li>/*end of php*/</li> </ol></div> <em onclick="copycode($('code_ufQ'));">复制代码</em> </div> </td></tr></table> <div id="comment_19255" class="cm"> </div> <div id="post_rate_div_19255"></div> <br><br>