<BR>$arrInsert = insertContent("array.php", "abcdef", 3, 10); <BR>unlink("array.php"); <BR>foreach($arrInsert as $value) <BR>{ <BR>file_put_contents("array.php", $value, FILE_APPEND); <BR>} <BR>function insertContent($source, $s, $iLine, $index) { <BR>$file_handle = fopen($source, "r"); <BR>$i = 0; <BR>$arr = array(); <BR>while (!feof($file_handle)) { <BR>$line = fgets($file_handle); <BR>++$i; <BR>if ($i == $iLine) { <BR>if($index == strlen($line)-1) <BR>$arr[] = substr($line, 0, strlen($line)-1) . $s . "n"; <BR>else <BR>$arr[] = substr($line, 0, $index) . $s . substr($line, $index); <BR>}else { <BR>$arr[] = $line; <BR>} <BR>} <BR>fclose($file_handle); <BR>return $arr; <BR>} <BR>//在多数据我们存储数据都是用数据库教程来操作,上面我们就是把数据以X格式存在文本中了,现在我要像操作数据库一样的,想删除那行就那行,保存数据也一样,怎么读取第几行就第几行了,所以我就写出来了php 在文件指<a>2本文来源gao*daima.com搞@代#码&网6</a><pre>搞gaodaima代码
定行插入数据实例哦。
?>
$iLine:为第几行,$index为第几个字符之前