03-Apr-2023
.
Admin
Hi Dev,
In this tutorial we will go over the demonstration of PHP count specific words from string example. This tutorial will give you a simple example of how to count find specific word in php?. this example will help you count specific words from string in php example. I would like to show you how to use function to count of specific words from string in php? .
In this example to php Count Specific Words from String from strings in PHP. in this example, we will use to substr_count() function used to Count Specific Words. so Let's see the following example with output.
Example: Count Specific Word from String
index.php
<?php
// Create String
$str = "Welcome to Nicesnippets.com, Nicesnippets.com is a blog website.";
// Displays the Count of Words
$result = substr_count($str, "Nicesnippets.com");
echo $result;
?>
Output:
2
I hope it could help you...
#PHP