#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    how do i count the number of hits when i search a file with the function strstr?

    Pieter
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    24
    Rep Power
    0
    So, your trying to count the number of times a string occurs in a string. I needed to do this a while ago.

    I got it to work by looping around until every instance as found. This wasnt very good though.

    The bets way Ive used is to explode the string by the string and subtract one.

    e.g.

    $count = explode ($string1, $string2);
    $count--;

    Hope this helps
    Sparky

    "If Builders Built Buildings the way programmers programmed programs, the first woodpecker that came along would destroy civilisation"

Similar Threads

  1. How to count max appearances?
    By Stew_McGruff in forum MySQL Help
    Replies: 8
    Last Post: December 13th, 2003, 06:27 PM
  2. words count in a sentence
    By alebaba in forum C Programming
    Replies: 5
    Last Post: November 22nd, 2003, 09:54 AM
  3. 2 Tables, count results
    By hausburger in forum MySQL Help
    Replies: 2
    Last Post: November 21st, 2003, 03:01 PM
  4. Need to count clicks.. with a twist.
    By Jadey in forum PHP Development
    Replies: 0
    Last Post: November 19th, 2003, 02:07 PM
  5. count specific items in column
    By st_moose in forum MySQL Help
    Replies: 2
    Last Post: June 20th, 2003, 02:40 PM

IMN logo majestic logo threadwatch logo seochat tools logo