Answers for "count character of string 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
2

get number of chars ina string php

$name = "Perú"; // With accent mark
echo strlen($name); // Display 5, because "ú" require 2 bytes.

$name = "Peru"; // Without accent mark
echo strlen($name); // Display 4
Posted by: Guest on May-13-2020
0

count_chars (PHP 4, PHP 5, PHP 7, PHP 8) count_chars — Return information about characters used in a string

<?php
$data = "Two Ts and one F.";

foreach (count_chars($data, 1) as $i => $val) {
   echo "There were $val instance(s) of \"" , chr($i) , "\" in the string.\n";
}
?>
Posted by: Guest on May-14-2022

Code answers related to "count character of string php"

Browse Popular Code Answers by Language