September 2001
Intermediate to advanced
768 pages
32h 45m
English
int substr_count(string string, string substring)
Counts the occurrences of a string within another string.
Returns:
Integer
Description:
substr_count() counts the number of times that substring occurs within string . If substring doesn’t occur within string, the function returns 0.
Version:
PHP 4+ since 4.0RC2
See also:
To get detailed statistics on the characters used in a string:
count_chars()
Example:
<?php // Don't get yer long-undies in a knot - the author is a Canuck! :) // Set a default value for message $message = ''; // If a message was posted, clean it up if (isset ($HTTP_POST_VARS['message'])) $message = striptags (stripslashes (trim ($HTTP_POST_VARS['message']))); ... |
Read now
Unlock full access