Development Finding a string in a text file

Discussion in 'Software' started by Sam0r, 12 Jun 2006.

  1. Sam0r

    Sam0r It's been a while

    Joined:
    24 Jun 2005
    Posts:
    1,900
    Likes Received:
    1
    Hi guys.

    I'm writing a PHP script to search through refferral logs from IIS/Apache and pull out all the google URLS and strip out the q=<text> part.

    Then I need it to output this to the user.

    How would I go about doing this? Currently I've got it to open the file and pop the contents into a variable, I can print this out fine.

    Cheers
     
  2. ajack

    ajack rox

    Joined:
    17 Apr 2003
    Posts:
    2,695
    Likes Received:
    2
    Use regexps, something like preg_grep() should sort ya.
     
  3. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0
    awk would be faster - man awk.

    Consider storing the results in a DB if they're big log files and/or the page will get lots of hits.
     
  4. eek

    eek CAMRA ***.

    Joined:
    23 Jan 2002
    Posts:
    1,600
    Likes Received:
    14
    Probably, however as he is using IIS I imagine he is using Windows so won't have awk.
     
  5. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0
    I saw Apache and assumed access to Linux. No one runs Apache/PHP on Windows do they?
     
  6. eek

    eek CAMRA ***.

    Joined:
    23 Jan 2002
    Posts:
    1,600
    Likes Received:
    14
    I do for dev work :p ;)
     
  7. JuMpErFLY

    JuMpErFLY Minimodder

    Joined:
    13 Mar 2003
    Posts:
    882
    Likes Received:
    1
    cygwin + awk
     
  8. Sam0r

    Sam0r It's been a while

    Joined:
    24 Jun 2005
    Posts:
    1,900
    Likes Received:
    1
    Its ok, we found a program do do it for us now!

    Thanks for the help though :)
     

Share This Page