Settings | Sign in | Sign up

The author has 1 post.

【技巧】foreach中使用引用

Floor 1 巨大八爪鱼 6/16/16 21:06
$arr = array(1, 2, 3);
foreach ($arr as $i => &$v) {
    $v *= 2;
}
echo join(', ', $arr);

输出:2, 4, 6

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.