dtyyrt4545 2015-12-27 05:39
浏览 28

PHP - 如何使用来自另一个静态文件的数据覆盖静态文件中特定数量的代码行,而不删除其余代码

I'm creating a simple static site generator for my small HTML blog site for educational reasons and I'm having a little trouble. I have a few .html files that need to be updated from time to time and decided to create a .php file that allows me to push a button and loop through all .html files applying the new code to the beginning of each .html file.

The new HTML code is located inside a .txt file called "header.txt". The loop should copy the new HTML from the "header.txt" file and apply it to each .html file, but only overwriting the exact number of lines as was found in the "header.txt" file, no more no less.

I've got the .php coded except for the button's code that will start the process of updating the files. That is the part I need help with. I tried a few different ways of embedding foreach and for loops with no success.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 python按要求编写程序
    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离