Dizideki bir çizgi değişimi değeri

1 Cevap php

Daha sonra verileri implode ve kaydetmek, belirli bir dizeye bir dizi içinde bir satır değerini değiştirmek gerekir. Aşağıdaki kodu kullanarak Im.

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);
?>

1 Cevap

Eğer zaten bir dizi elemanının sayısal dizini varsa index into an array?, sadece devam edin ve bunu değiştirmek olduğunu fark yok:

$arr[$index] = "some new stuff";

Sihirli güncellendi.