PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<substr_comparesubstr_replace>
Last updated: Mon, 16 Jul 2012

substr_count

(PHP 4, PHP 5)

substr_count -- Count the number of substring occurrences

Description

int substr_count ( string haystack, string needle )

substr_count() returns the number of times the needle substring occurs in the haystack string. Please note that needle is case sensitive.

例子 1. substr_count() example

<?php
echo substr_count("This is a test", "is"); // prints out 2
?>

See also count_chars(), strpos(), substr(), and strstr().




<substr_comparesubstr_replace>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST