dan182skater Posted June 21, 2006 Share Posted June 21, 2006 Hello, I have a folder of like 300 PHP files and want to search for a specific line of code that would only be in one of the files. The problem is I don't have time to open each of the 300 files and search for the code. Is there a way a program that lets me search within all the PHP files to find that line of code? Or at least find the file that the line of code would be in? THANKS!-Daniel Quote Link to comment Share on other sites More sharing options...
zq29 Posted June 21, 2006 Share Posted June 21, 2006 You could use glob() - file() - strpos() Quote Link to comment Share on other sites More sharing options...
dan182skater Posted June 27, 2006 Author Share Posted June 27, 2006 thanks for the reply, but that made no sense to me. Quote Link to comment Share on other sites More sharing options...
zq29 Posted June 27, 2006 Share Posted June 27, 2006 [!--quoteo(post=388343:date=Jun 27 2006, 04:48 AM:name=dan182skater)--][div class=\'quotetop\']QUOTE(dan182skater @ Jun 27 2006, 04:48 AM) [snapback]388343[/snapback][/div][div class=\'quotemain\'][!--quotec--]thanks for the reply, but that made no sense to me.[/quote]I meant you could write a script with the PHP functions I listed to search your files. Something like this...[code]<?phpforeach(glob("dir/to/files/*.php") as $f) { $lines = file($f); foreach($lines as $l) { if(strpos($l,"I am looking for this in my code") !== FALSE) echo "<p>WE HAVE A MATCH IN $f</p>"; }}?>[/code]This is untested, so I'm not sure if it would work. Failingthis, doesn't Windows "find" search within files? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.