Ben Mektubun a, belirli bir dize görünür kaç örnekleri kontrol etmek istiyorum.
Bunun için fonksiyonu nedir? Ben bir tamsayı değeri döndürmek gerekir.
Sen işlevini kullanabilirsiniz: substr_count
Örnek:
$str = "I love stackoverflow";
echo substr_count($str,'o'); // prints 3
I substr_count hile yapabilir herhalde ;-)
For example, this portion of code :
$str = 'abcdazerty';
echo substr_count($str, 'a');
Size aşağıdaki çıktıyı almak istiyorum:
2
And, quoting :
int substr_count ( string $haystack ,
string $needle [, int $offset = 0
[, int $length ]] )
substr_count()returns the number of times theneedlesubstring occurs in thehaystackstring. Please note that needle is case sensitive.
Eğer gereken herhangi bir fonksiyonu bulmak için PHP string fonksiyonları kılavuzuna başvurabilirsiniz, http://php.net/strings