Jump to content

Search within PHP files


dan182skater

Recommended Posts

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
Share on other sites

[!--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]<?php
foreach(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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.