将文本插入现有文件(在指定行)。 [英] Inserting text into an existing file (at a specified line).

查看:61
本文介绍了将文本插入现有文件(在指定行)。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想在任何文件的第5行写,然后如何在php中实现这个?


shoonya

suppose i want to write on the 5th line of any file then how to implement this in php??

shoonya

推荐答案




你看过php.net吗?尝试 fopen


Purple
Hi,

did you take a look at php.net ? try fopen

Purple






你看过php吗?网?尝试 fopen


紫色
Hi,

did you take a look at php.net ? try fopen

Purple



fopen用于打开文件

i我正在谈论在任何给定的行上写作

(首先阅读问题)


shoonya

fopen is for opening the file
i am talking about writing on any given line
(read the question first)

shoonya


嘿谢谢重定向问题shoonya,


如果你想操作文件,fopen并不是一个糟糕的起点。如果您按照最初的建议阅读php.net上的页面,您会发现以下代码几乎可以满足您的需求..


以下剪切直接来自php.net - 发布在那里naidim at gmail dot com


虽然PHP没有将文本插入文件中间的功能,但这并不复杂。


[PHP]<?php

函数addRSSItem(
Hey thanks for the redirect to the question shoonya,

fopen is not a bad place to start if you want to manipulate files. If you read the page on php.net as initially suggested you will find the following code which almost does what you want..

The following cut directly from php.net - posted there by naidim at gmail dot com

While PHP does not have a function to insert text into the middle of a file, it is not that complicated to do.

[PHP]<?php
function addRSSItem(


这篇关于将文本插入现有文件(在指定行)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆