Answers for "count number of times character appears in string php"

PHP
3

php count specific characters in string

<?php
//you can use the substr_count function
$str = "this is a test string"; 

echo substr_count($str, "s");  //Output: 4
?>
Posted by: Guest on May-23-2021
0

total no of occurances in string php

$str = "cdcdcdcdeeeef";
echo substr_count($str, 'c'); 


//please note needle is case sensitive
Posted by: Guest on June-17-2021

Code answers related to "count number of times character appears in string php"

Browse Popular Code Answers by Language