diff --git a/reference/strings/functions/substr-count.xml b/reference/strings/functions/substr-count.xml index a2c3ddb33c..85fa15e656 100644 --- a/reference/strings/functions/substr-count.xml +++ b/reference/strings/functions/substr-count.xml @@ -1,44 +1,152 @@ - + - - - substr_count - Count the number of substring occurrences - - - Description - - intsubstr_count - stringhaystack - stringneedle - - - substr_count returns the number of times the - needle substring occurs in the - haystack string. Please note that - needle is case sensitive. - + + + substr_count + Count the number of substring occurrences + + + &reftitle.description; + + intsubstr_count + stringhaystack + stringneedle + intoffset + intlength + + + substr_count returns the number of times the + needle substring occurs in the + haystack string. Please note that + needle is case sensitive. + + + + This function doesn't count overlapped substrings. See the example below! + + + - - - <function>substr_count</function> example - + + &reftitle.parameters; + + + + haystack + + + The string to search in + + + + + needle + + + The substring to search for + + + + + offset + + + The offset where to start counting + + + + + length + + + The maximum legth after the specified offset to search for the + substring. It outputs a warning if the offset plus the length is + greater than the haystack length. + + + + + + + + + &reftitle.returnvalues; + + This functions returns an integer. + + + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 5.1.0 + + Added the offset and + the length parameters + + + + + + + + + + &reftitle.examples; + + + A <function>substr_count</function> example + 14 +echo substr_count($text, 'is', 5, 10); + + +// prints only 1, because it doesn't count overlapped subtrings +$text2 = 'gcdgcdgcd'; +echo substr_count($text2, 'gcdgcd'); ?> ]]> - - - - - See also count_chars, - strpos, substr, - and strstr. - - - + + + + + + + &reftitle.seealso; + + + count_chars + strpos + substr + strstr + + + +