Answers for "how to count the number of occurrences of all character in a string in php"

PHP
5

how to count string characters in php

<?php
$str1 = 'Hello world!';
echo strlen($str1); // Outputs: 12
Posted by: Guest on June-27-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 "how to count the number of occurrences of all character in a string in php"

Browse Popular Code Answers by Language