★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum5/HTML/002237.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  PHP
  count hits when searching with strstr

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   count hits when searching with strstr
pieter guis
Member
posted August 02, 2000 05:14 AM     Click Here to See the Profile for pieter guis   Click Here to Email pieter guis     Edit/Delete Message Reply w/Quote
how do i count the number of hits when i search a file with the function strstr?

Pieter

Sparks
Member
posted August 02, 2000 12:20 PM     Click Here to See the Profile for Sparks   Click Here to Email Sparks     Edit/Delete Message Reply w/Quote
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"

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.