check variable against an array of words.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JasonC
    New Member
    • Nov 2006
    • 3

    check variable against an array of words.

    Hi,

    First time posting here so please be gentle!

    I wish to check a variable for a number of words that are in a array.

    Not sure if this is the best way to do it, but this is what i have.

    I have my own counter system that counts every visitor, but some of these visits are from BOTS, spiders..

    So i wish to have a method of searching the HTTP_USER_AGENT for certain words i put in a array.

    What i am after is how i get the words in an array and how i then get the script to check the HTTP_USER_AGENT for a word in the array and if so it will not complete the script. (not add to the counter)
    if none of the words are in the HTTP_USER_AGENT then it will add to the counter.

    so something like?

    <?
    // do array

    // check if HTTP_USER_AGENT contains a word from array
    if () {
    // increase counter if none of the words are in HTTP_USER_AGENT
    include(increas e.php);
    }

    ?>


    its the bit between the if () that i have no idea about, any help would be great.

    cheers in advance for your help.

    Jason
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You already have exactly the same thread opened in the www.codingforums.com PHP forum at http://www.codingforums.com/showthread.php?t=100965 . And some people really helped you out!! Your exact last words in that forum thread were
    Originally posted by jasonc310771
    but yes the code does work.

    thank you so much for your help.

    thank you for you patients
    Ronald :cool:

    Comment

    • cassbiz
      New Member
      • Oct 2006
      • 202

      #3
      You can save yourself a lot of trouble by just going out and getting AWSTATS

      That will give you everything in a nutshell and will come right off of your http logs.

      Comment

      Working...