Copy code The code is as follows:
$arrInsert = insertContent("array.php", "abcdef", 3, 10);
unlink("array.php");
foreach($arrInsert as $value)
{
file_put_contents("array.php", $value, FILE_APPEND);
}
function insertContent($source, $s, $iLine, $index) {
$file_handle = fopen($source, "r");
$i = 0;
$arr = array();
while (!feof($file_handle)) {
$line = fgets($file_handle);
++$i;
if ($i == $iLine) {
if ($index == strlen($line)-1)
$arr[] = substr($line, 0, strlen($line)-1) . $s . "n";
else
$arr[] = substr($line, 0, $index) . $s . substr($line, $index);
}else {
$arr[] = $line;
}
}
fclose($file_handle);
return $arr;
}
//In Multidata, we use the database tutorial to store data. Above we just use X The format is stored in the text. Now I have to operate it like a database. If I want to delete the row, just use that row. The same goes for saving the data. How to read the row? So I wrote it out in php and specified it in the file. Row insert data instance.
?>
$iLine: which line is it, $index is which character before it
http://www.bkjia.com/PHPjc/321832.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321832.htmlTechArticleCopy the code as follows: $arrInsert = insertContent("array.php", "abcdef", 3, 10) ; unlink("array.php"); foreach($arrInsert as $value) { file_put_contents("array.php", $value, FIL...