Linked Questions
11 questions linked to/from Replace string in text file using PHP
0 votes
1 answer
941 views
How to find and replace text in text file using php? [duplicate]
i need to find a line and change it to whatever user will type in input i didnt write this code pls help <?php $myfile = 'test.txt'; $lines = file($myFile, FILE_IGNORE_NEW_LINES); $lines[4] = $...
-3 votes
1 answer
111 views
Replace placeholder in text file with user input [duplicate]
I have a string that comes from an android application. I also have a file (unknown.txt) which contains a line "20,30,40,2,5,?". I want to write a PHP script which is called by the android ...
2 votes
1 answer
2k views
Find and Replace Curl Output PHP
I have two websites. I would like to curl to a page on website #1 to retrieve html code which has links to my favorite twitch streams, embed in to my page using their api. Using this curl output, ...
1 vote
4 answers
2k views
How to update static content in multiple HTML pages
I have some 1000 html pages. I need to update the names which is present at the footer of every html page. What is the best possible efficient way of updating these html pages instead of editing each ...
3 votes
3 answers
639 views
How to edit the variables of a php file with another php file
Ok so I want to do something similar to how Simple Machine Forum edits some variable within the Admin panel on the forum. For instance I have a settings.php file. I want tool.php to open and find all ...
0 votes
1 answer
438 views
php replace an string on exist file .env
my question is similiar like this : Replace string in text file using PHP but i want replace by spesification variable for example, i have already file exist .env variable_1=data_2021 variable_99=...
0 votes
2 answers
145 views
PHP : How to Replace some text from n th line to m th line from file?
I have a file like some.txt having content : #start-first Line 1 Line 2 Line 3 #end-first #start-second Line 1 Line 2 Line 3 Line 4 #end-second #start-n Line 1 Line 2 Line 3 Line 4 ... ... #end-n I ...
1 vote
2 answers
230 views
PHP replace/update a line in large text file
Let's consider we got following format text file with a size around 1Gb: ... li1 li2 li3 ... My task is to update line li2 to line2. Following will not work: $fd = fopen("file", 'c+'); // .. // ...
-1 votes
1 answer
153 views
delete a line and replace with new text in a txt file
i have a txt file containing 20 lines i want to replace line # 4 with a new text from an input ...i have tried this and some others but not solving my problem. PHP Code <?php if(isset($_POST['...
0 votes
1 answer
84 views
How to replace a word in a file with a hyperlink in PHP?
I need a help with replacing a word from a text file to a link using php This is my code: <?php $search = 'google'; $lines = file('f.txt'); foreach($lines as $line) { if(strpos($line, $search) ...
0 votes
0 answers
52 views
How to replace text inside a PHP Document?
I am making a wordpress plugin, you can edit a page's title with it. The title will be an H1 Tag with the ID of featuredTitle. <h1 id="featuredTitle">This text will be replaced!</h1&...