How can I use PHP to open another PHP file, find a line, and replace it with something else??? If it helps, here's the document that needs to be opened...
$phpbb_root_path . 'includes/functions_alpha.' . $phpEx
Here are the two lines that need to be found...
$select_sidebar = 8;
and
$select_sidebar = 9;
These lines are not right next to each other.
And I need them to be replaced with...
$select_sidebar = {$module_id1};
and
$select_sidebar = {$module_id2};
Please note that I don't want it to say $select_sidebar = $module_id1, I want it to say $select_sidebar = (and then the value of $module_id1).
So, any help is appreciated.
Find and replace in PHP
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Find and replace in PHP
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
- igorw
- Past Contributor
- Posts: 1967
- Joined: 01 Jun 2006, 20:48
- Real name: Igor [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Find and replace in PHP
Last edited by igorw on 12 Jan 2015, 23:59, edited 2 times in total.
Reason: write needs to be fwrite, thanks leory for calling me a nub
Reason: write needs to be fwrite, thanks leory for calling me a nub
- we're poor!
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Re: Find and replace in PHP
does this only work in PHP5???
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
- igorw
- Past Contributor
- Posts: 1967
- Joined: 01 Jun 2006, 20:48
- Real name: Igor [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Find and replace in PHP
Nope, works in 4.3 as well. If you were using PHP5 only, you could however use file_put_contents().
- we're poor!
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Re: Find and replace in PHP
Nope, I want it to work with everything phpBB3 works with.
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
Return to “phpBB Development discussion”
Who is online
Users browsing this forum: No registered users and 18 guests