Replace text in a file with php


















Viewed 60k times. Improve this question. Add a comment. Active Oldest Votes. Improve this answer. Jurgen Vinju 5, 14 14 silver badges 25 25 bronze badges. The less memory intensive approach is exactly what I needed simple and easy to understand You have to overwrite the entire file. For the big file the algorithm is slightly different, but quite the same in general. Important part is file locking that's why we prefer a database.

Your Common Sense Your Common Sense k 37 37 gold badges silver badges bronze badges. Dan Heberden Dan Heberden If you don't know the line, you will have to search over all lines. Community Bot 1 1 1 silver badge. Gordon Gordon k 69 69 gold badges silver badges bronze badges. ChickenFeet ChickenFeet 2, 20 20 silver badges 24 24 bronze badges.

Calum 4, 1 1 gold badge 21 21 silver badges 27 27 bronze badges. Vasic Danijel Vasic Danijel 31 6 6 bronze badges. Usage: replace "message", "database. Tiernan Crotty Tiernan Crotty 10 10 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta.

New post summary designs on greatest hits now, everywhere else eventually. I need to open a text file and replace a string. Improve this question. Peter Mortensen Make sure you have write permissions on the msghistory.

Is this right? You have a syntax error. It's something small im missing Show 1 more comment. Active Oldest Votes. Improve this answer.

Spencer O'Reilly 1 1 gold badge 6 6 silver badges 18 18 bronze badges. Ahmad Zafar M. Ahmad Zafar 4, 3 3 gold badges 30 30 silver badges 44 44 bronze badges. Add a comment. Thanks to your comments. Adrian Goia Adrian Goia 3 3 silver badges 7 7 bronze badges.

May I ask why you use explode, implode? I followed your advice and it works great! Pedroski: Hello dear fellow! This was simply my way of thinking. Thanks, I ask because I don't really understand this stuff. All I know is: it woks, and speed doesn't matter to me! Rachid Loukili Rachid Loukili 1 1 silver badge 9 9 bronze badges. Sign up or log in Sign up using Google.



0コメント

  • 1000 / 1000