Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
PHP – How to return the character count of a string using iconv_strlen()?
In PHP, the iconv_strlen() function is used to return the character count of a given string. This is an inbuilt function in PHP that is first used in PHP 5 version. Encoding is nullable from PHP 8.0.
Syntax
string iconv_strlen(str $string, str $encoding)
Parameters
This PHP function accepts two parameters: $string and $encoding.
$string− The $string parameter is used for the input string.
$encoding− If the $encoding parameter is absent or it is null, then the string is assumed to be encoded in iconv.internal_encoding.
Return Values
The iconv_strlen() function returns the list of characters count which is present in the given string, or it returns False if an error occurs during encoding.
Example
<?php
//UTF-8 string
$integer = iconv_strlen("hello world!", "UTF-8");
// It will returns the number of character
var_dump($integer);
?>
Output
int(12)
Advertisements
