Php inserts a data instance in the specified row of the file. The php Tutorial inserts a data instance in the specified row of the file. for php files, it is complicated to insert data at the specified position, next let's take a look at the link in the file specified row insert php Tutorial in the file specified row insert data instance
For PHP file operations, it is complicated to insert data at the specified position. let's take a look at the link and insert the data instance in the specified row of the 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 )){
$ 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 multi-data storage, data is stored in the database tutorial. in the above example, the data is stored in the text in the X format. now I want to operate like a database, the row that you want to delete is the same as the row that stores the data. how to read the row that contains the row number is the same, so I wrote php to insert the data instance in the specified row of the file.
?>
$ ILine: the number of lines, $ index before the number of characters
Inserting a data instance in the specified row of the file using the dig command is complicated for the PHP file operation. Next let's take a look at the link inserted in the specified row of the file...