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