SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    Non-Member
    Join Date
    Nov 2003
    Location
    Watervliet, mi
    Posts
    651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    If variable contains

    I want to only do something if a variable contains the text:

    Logfile of HijackThis

    There will be quite a bit of text bother before and after this but I can't think of the function to search through a variable LOL It's been a while since I did any coding so I've forgotten pretty much everything

  2. #2
    Scary's On The Wall
    Join Date
    Apr 2003
    Location
    PA
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's one way:

    PHP Code:
    if (strpos($string'Logfile of HijackThis') !== FALSE) {

    echo 
    '"Logfile of HijackThis" found!';


    Use stripos() instead of strpos() if you want it to be case-insensitive.
    Last edited by Haleden; Apr 30, 2005 at 16:07. Reason: Cleaning it up

  3. #3
    Non-Member
    Join Date
    Nov 2003
    Location
    Watervliet, mi
    Posts
    651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, that's working great I've had over 40k submissions in the past 2mnths to a system and doing stuff like this will help automate the process for filtering out the junk. The system I'm adding this to is http://hjt.iamnotageek.com/ if you're wondering. I haven't had any time for programming in a while so I've forgotten alot LOL

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Ontario, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, an alternative to this you can use regular expression functions such as preg_match() but, if you've been away from PHP for a while, don't worry about it
    Brock Ferguson
    Lead Developer, Caribou CMS
    A Subscription/Membership CMS and Ecommerce Platform - FREE Trial


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •