PHP Find/Replace Script - Printable Version +- Jiggmin's Village (https://jiggmin2.com/forums) +-- Forum: Turing Machines (https://jiggmin2.com/forums/forumdisplay.php?fid=19) +--- Forum: Coding and Development (https://jiggmin2.com/forums/forumdisplay.php?fid=20) +--- Thread: PHP Find/Replace Script (/showthread.php?tid=1341) |
PHP Find/Replace Script - bls1999 - 8th December 2018 When sifting through old code trying to find different names of things, I've found it extremely useful and time-saving to run a PHP script from the command line that searches through all the files in a directory on my computer for a search term. On this particular project, I have it set to sift through ActionScript files only, but you can set it to anything. Here it is, if anyone's interested: PHP Code: <?php The arguments are: [0] = File [1] = Find [2] = Strict? (yes/true uses preg_match to match exact words, no/false uses strpos for a character match) [3] = Replace A sample run on the command line for me would be: Code: php /Users/ben/Projects/SuperSecretThings/search.php "Example" true That would give me a strict, case-sensitive result for the complete word "Example" as opposed to also getting a result for "ExampleData". Anyway, yep. I hope y'all learned something and/or have a use for the code in your own projects. RE: PHP Find/Replace Script - xGuest - 8th December 2018 interesting, even though I dont know how to code at all and that xd RE: PHP Find/Replace Script - Ashley766 - 8th December 2018 (8th December 2018, 5:26 AM)xGuest Wrote: interesting, even though I dont know how to code at all and that xd Haha, I'm actually learning PHP rn, so I understand a little bit |