0
我需要將數組中某一行的值更改爲給定字符串,然後分解並保存數據。我使用下面的代碼。更改數組中某一行的值
行是該表的行。
目標是我想要更新的數組中的特定行。
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);
?>
所以在我爆炸信息後,我可以做一個$ info [$ target] =「新東西」; ? – mrpatg 2009-10-27 06:40:46
你可以。 * Iff *我明白你的代碼正確。它並沒有在「告訴我你在做什麼」的規模上居於高位。 – Joey 2009-10-27 06:54:27