NYCPHP Meetup

NYPHP.org

[nycphp-talk] searching inside php source files

Konstantin K kkrutoi at gmail.com
Wed Dec 30 04:05:43 EST 2009


Hey folks,

I went with the following and it works nicely:

$path_to_file = 'path/to/the/file';
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace("what_to_replace","replace_with",$file_contents);
file_put_contents($path_to_file,$file_contents);

courtesy of: http://stackoverflow.com/questions/1438563/find-and-replace-in-a-file

Konstantin


On Tue, Dec 29, 2009 at 11:39 PM, Konstantin K <kkrutoi at gmail.com> wrote:
> I meant to say programmatically.. :)
>
> On Tue, Dec 29, 2009 at 11:32 PM, Eddie Drapkin <oorza2k5 at gmail.com> wrote:
>> On Tue, Dec 29, 2009 at 11:30 PM, Konstantin K <kkrutoi at gmail.com> wrote:
>>> Hi folks,
>>>
>>> I need to search for and replace a string inside many PHP (source) files
>>>
>>> I was thinking of using http://pear.php.net/package/File_SearchReplace
>>> but it's not maintained anymore.
>>>
>>> 1. Any suggestions how I should approach this problem?
>>> 2. What tools do you recommend?
>>> 3. Should I be on the look out or concerned about any gotcha's since
>>> this is actual source code, not normal text?
>>>
>>> Thanks for any ideas!
>>> Konstantin
>>> _______________________________________________
>>> New York PHP Users Group Community Talk Mailing List
>>> http://lists.nyphp.org/mailman/listinfo/talk
>>>
>>> http://www.nyphp.org/Show-Participation
>>>
>>
>> This is built into Eclipse, as far as I know.  Search (menu) -> file -> replace.
>> _______________________________________________
>> New York PHP Users Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/Show-Participation
>>
>



More information about the talk mailing list