【发布时间】:2009-10-27 06:28:44
【问题描述】:
我需要将数组中一行的值更改为给定的字符串,然后内爆并保存数据。我使用下面的代码。
row 是表格的行。
target 是数组中我要更新的特定行。
nfv 是我要放入数组的新字符串。
<?
$rowpre = $_GET['row'];
$newfieldvalue = $_GET['nfv'];
$row = --$rowpre;
$data = file_get_contents("temp.php");
$csvpre = explode("###", $data);
$i = 0;
foreach ( $csvpre AS $key => $value){
$i++;
if($i = $row){
$info = explode("%%", $value);
$j = 0;
foreach ( $info as $key => $value ){
$j++;
if($j == $target){
/*change the value of this line to $newfieldvalue*/
}
}
}
}
$presave = implode("%%", $info);
$save = implode("###", $presave);
$fh = fopen("temp.php", 'w') or die("can't open file");
fwrite($fh, $save);
fclose($fh);
?>
【问题讨论】: