Home > Backend Development > PHP Tutorial > php insert data instance in specified line of file_PHP tutorial

php insert data instance in specified line of file_PHP tutorial

WBOY
Release: 2016-07-20 11:07:36
Original
967 people have browsed it

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

true
http: //www.bkjia.com/PHPjc/444951.html

TechArticlephp tutorial inserting data into the specified line of the file example For php file operations, it is more complicated to insert data at the specified location. Okay, let’s take a look at the relationship and insert it in the specified line of the file...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template