I need to change the value of a line within an array to a given string, then implode and save the data. Im using the code below.
row is the row of the table.
target is the specific line in the array which i want to update.
nfv is the new string i want to put into the array.
<?
$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);
?>