dongzantai7570 2010-12-16 11:50 采纳率: 0%
浏览 659

php file_put_contents ...我不能在开头追加?

<?php
$file = 'people.txt';
// The new person to add to the file
$person = "John Smith
";
// Write the contents to the file, 
// using the FILE_APPEND flag to append the content to the end of the file
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
 file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
?>

This will append the content at the end of the file. i want to write newest at the beginning of the file.

  • 写回答

4条回答 默认 最新

  • douzhi3776 2010-12-16 11:51
    关注

    As the manual page shows, there is no flag to prepend data.

    You will need to read the whole file using file_get_contents() first, prepend the value, and save the whole string.

    评论

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像