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 Link to comment https://forums.phpfreaks.com/topic/12510-search-within-php-files/ Share on other sites More sharing options...
zq29 Posted June 21, 2006 Share Posted June 21, 2006 You could use glob() - file() - strpos() Link to comment https://forums.phpfreaks.com/topic/12510-search-within-php-files/#findComment-47935 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. Link to comment https://forums.phpfreaks.com/topic/12510-search-within-php-files/#findComment-49932 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? Link to comment https://forums.phpfreaks.com/topic/12510-search-within-php-files/#findComment-49977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.