PHP substr_count() Function - Seditio Yazılım - Seditio CMS Türkiye

Yayınımız yeniliklerle beraber yeni sitemizden devam ediyor. Seditio.com.tr takip edin.

User profile picture

Kaan

Seditio CMS

PHP substr_count() Function

Count the number of times "world" occurs in the string:

<?php
echo substr_count("Hello world. The world is nice","world");
?>

The substr_count() function counts the number of times a substring occurs in a string.

Note: The substring is case-sensitive.

Note: This function does not count overlapped substrings (see example 2).

Note: This function generates a warning if the start parameter plus the length parameter is greater than the string length (see example 3).

<?php
$str = "This is nice";
echo strlen($str)."<br>"; // Using strlen() to return the string length
echo substr_count($str,"is")."<br>"; // The number of times "is" occurs in the string
echo substr_count($str,"is",2)."<br>"; // The string is now reduced to "is is nice"
echo substr_count($str,"is",3)."<br>"; // The string is now reduced to "s is nice"
echo substr_count($str,"is",3,3)."<br>"; // The string is now reduced to "s i"
?>

php substr_count() function

İlginizi Çekebilir

Yorumlar

Henüz yorum yapılmamıştır.