Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to count string characters in php

<?php
$str1 = 'Hello world!';
echo strlen($str1); // Outputs: 12
Comment

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.
";
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel run migration 
Php :: pi() in php 
Php :: var_dump _post php 
Php :: function exists php 
Php :: wordpress custom theme style.css 
Php :: php 3 digit decimal 
Php :: get all post values in php 
Php :: calculate person age by birthdate php 
Php :: date_default_timezone_set for india in php laravel 
Php :: orwherebetween laravel 
Php :: wordpress if admin 
Php :: check if constant is defined php 
Php :: formate date using carbon in laravel blade 
Php :: error log array 
Php :: get last 30 days records in laravel 
Php :: php is string 
Php :: get year in laravel 8 
Php :: php foreach if last item 
Php :: wp-config override site url 
Php :: how get file size in laravel 
Php :: wp get user meta 
Php :: laravel withtrashed 
Php :: laravel return 1 as true 
Php :: first day of month php 
Php :: how to connect to a database in php 
Php :: php convert string to utf8 
Php :: how to calculate days between two dates in php 
Php :: group by laravel 
Php :: highlight search text in php 
Php :: old function use in checkbox selected in laravel blade 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =