counting matches with eregi()

From: Date: Wed, 15 Nov 2000 22:09:04 +0000
Subject: counting matches with eregi()
Groups: php.general 
Request: Send a blank email to php-general+get-25533@lists.php.net to get a copy of this message
I want to count the number of times a word appears in a string. I am using php3/linux Say I have a string: $string = "my house is a new house but not a big house in my household" I want to count how many times the word 'house' appears. If I use parentheses and include a $matches array in an eregi function, it stores partial matches, not a count of full matches in the entire string. Also the manual says that word boundary \b should work with php3, but the series of statments: $pattern = "\bhouse\b" $test = eregi($pattern, $string, $matches); return with no matches. I need to make sure that 'household' is not included in the count of whole words. what am i doing wrong? _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com

« previous php.general (#25533) next »