Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to count string characters in php

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

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
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
:: accessing json data in php 
Php ::  
Php ::  
Php :: how to include file in laravel blade 
:: how to get attachments to emails php 
Php ::  
Php :: cambiare pagina php 
Php :: php for next loop step 
Php :: laravel logger 
:: laravel collective form include image 
Php :: php typeof 
:: php array_walk 
:: nl2br() php 
Php ::  
Php :: Termlaravel validation exists array rules 
Php :: pdf watermark dengan laravel 
::  
:: Access-Control-Allow-Origin php laravel 
Php ::  
Php :: unique key value array php 
::  
::  
:: how to write orderby in join query with where clause in codeigniter 
Php :: unset php return array 
:: filter var php function 
Php ::  
:: php stop loading page 
:: get the current datetime in php when button is clicked 
:: wordpress autoload composer 
Php :: php dirpath multiple file extensions 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =