php中foreach数组并修改数组

foreach数组并修改数组值,需要使用&
举例说说:

		/*
		处理数组
		$list = [
			'one'   => 1,
			'tow'   => 2,
			'three'	=> 3,
		]
		*/
        foreach ($list as $id => &$info) {
     
       	    // 添加
            $info['four'] = 4;
            // 删除
            unset($info['one']);
            // 修改
            $info['three'] = $info['three'] * 2;
        }

你可能感兴趣的:(php)