WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World
Count the number of substring occurrences

mb_substr_count

(PHP 4 >= 4.3.0, PHP 5)

mb_substr_countCount the number of substring occurrences

Description

int mb_substr_count ( string $haystack , string $needle [, string $encoding ] )

Counts the number of times the needle substring occurs in the haystack string.

Parameters

haystack

The string being checked.

needle

The string being found.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

The number of times the needle substring occurs in the haystack string.

Examples

Example #1 mb_substr_count() example

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

See Also


Counting the number of words in user-supplied text
Categories : PHP, Strings
Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays.
Categories : Calendar, Date Time, PHP, Databases, MySQL
How to count the number of lines in a file
Categories : PHP, Filesystem



a counter in php using gif images (0.gif, 1.gif, etc) and a text file to save the number of visitors
Categories : PHP, Graphics
Creating thumbnails from MySQL Blobs online
Categories : PHP, MySQL, Graphics, HTML and PHP, Databases
MySQL and substrings.
Categories : MySQL, Strings, Date Time, Databases
Convert an IP address to the country name and display them to your visitor.
Categories : PHP, PHP Classes
Word count like function Ver.1.0! This function can count your input text and display only part of it (like a description) without cutting words in half.Very useful for portal like sites.
Categories : PHP, Strings
Class for processing image (resizing the image size to create thumb nails and small images from actual image without loosing the aspect ratio of the image)
Categories : PHP, PHP Classes, Graphics
PHPixel - output of 1 pixel transparent/colored gif for counters etc.
Categories : PHP, Graphics, HTML and PHP
Scramble Eggs - php class to scramble/encode
Categories : PHP, PHP Classes, Security, Encryption
Validating Credit Card Numbers Without Bank Involvement
Categories : Credit Cards, Ecommerce, Java Script
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
Credit Card Numbers for testing
Categories : Credit Cards, Ecommerce, Debugging