php tutorial Insert data instance in specified line of file
For php file operation, it is more complicated to insert data in specified position. Let’s take a look at the relationship and insert data instance in specified line of file.
$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)) {
strlen($line)-1)
$arr[] = substr($line, 0, $index) . $s . substr($line, $index);
}else {
> }
fclose($file_handle);
return $arr;
}
//In multidata, we use database tutorials to store data. Above we store the data in X format The text is in. Now I want to operate it like a database. I want to delete that row. The same goes for saving data. How to read the first row? So I wrote php and inserted it into the specified row of the file. Data examples.
?>
$iLine: which line is it, $index is which character before it
http://www.bkjia.com/PHPjc/444951.html
www.bkjia.com