Re: [PHP] one pattern, one string, multiple results

2001-09-26 Thread * RzE:

Original message
From: Richard Baskett [EMAIL PROTECTED]
Date: Wed, Sep 26, 2001 at 12:01:11AM -0700
Message-ID: [EMAIL PROTECTED]
Subject: [PHP] one pattern, one string, multiple results

 I just can not seem to figure this out.
 
 If i have a pattern 'arc' and I want to search the string:
 an arc is an archer, but what about marc and darcy?
 
 How can I find out how many occurances of arc is within that string?  I know
 I can do an explode and then compare it, but when you have huge amounts of
 text... is this the best way?  Or is there something better?  Any help would
 be great I have been struggling with this for awhile, since I really do not
 want to explode, pun intended :)
 
 Rick

/Original message

Reply

This you do the job exactly as you want:

http://www.php.net/manual/en/function.substr-count.php

int substr_count (string haystrack, string needle)

/Reply

-- 

* RzE:


-- 
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] one pattern, one string, multiple results

2001-09-26 Thread Maxim Maletsky \(PHPBeginner.com\)


Hi Richard.

Subsrt_count() is what you are looking for:
int substr_count (string haystrack, string needle)
php.net/substr_count

P.S: Helen Fielding's Bridget Jones Diary is a nice novel, hun?


Maxim Maletsky
PHPBeginner.com



-Original Message-
From: Richard Baskett [mailto:[EMAIL PROTECTED]] 
Sent: mercoledi 26 settembre 2001 9.01
To: PHP General
Subject: [PHP] one pattern, one string, multiple results


I just can not seem to figure this out.

If i have a pattern 'arc' and I want to search the string:
an arc is an archer, but what about marc and darcy?

How can I find out how many occurances of arc is within that string?  I
know I can do an explode and then compare it, but when you have huge
amounts of text... is this the best way?  Or is there something better?
Any help would be great I have been struggling with this for awhile,
since I really do not want to explode, pun intended :)

Rick


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] one pattern, one string, multiple results

2001-09-26 Thread Richard Baskett

Thank you much!  I was going to use preg_grep, preg_replace, preg_match,
preg_match_all something like that, but this subsrt_count() will do the
trick nicely!  Thank you very much!

Rick

 Hi Richard.
 
 Subsrt_count() is what you are looking for:
 int substr_count (string haystrack, string needle)
 php.net/substr_count
 
 P.S: Helen Fielding's Bridget Jones Diary is a nice novel, hun?
 
 
 Maxim Maletsky
 PHPBeginner.com
 
 
 
 -Original Message-
 From: Richard Baskett [mailto:[EMAIL PROTECTED]]
 Sent: mercoledi 26 settembre 2001 9.01
 To: PHP General
 Subject: [PHP] one pattern, one string, multiple results
 
 
 I just can not seem to figure this out.
 
 If i have a pattern 'arc' and I want to search the string:
 an arc is an archer, but what about marc and darcy?
 
 How can I find out how many occurances of arc is within that string?  I
 know I can do an explode and then compare it, but when you have huge
 amounts of text... is this the best way?  Or is there something better?
 Any help would be great I have been struggling with this for awhile,
 since I really do not want to explode, pun intended :)
 
 Rick
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] To
 contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]