PHP iconv_strlen() Function Last Updated : 09 May, 2024 Comments Improve Suggest changes Like Article Like Report The iconv_strlen() is an inbuilt function in PHP that is used to calculate the length of a string. It is very useful when your working string is encoded in a different character set, as it can accurately determine the length regardless of the encoding. Syntax:iconv_strlen(string $string, ?string $encoding = null) : int | falseParameters:$string: The input string from which you want to extract a portion.$encoding(optional): This parameter is optional to use. If not provided it will use null.Return Value:The return value of the iconv_strlen() function is the length of the string. If this function fails to get the length of the string. It will return false. Example 1: The following program demonstrates the iconv_strlen() function. PHP <?php $str = "GeeksforGeeks"; $number = iconv_strlen($str) ; echo "String Length is = ".$number // Output: 9 ?> OutputString Length is = 13Example 2: The following program demonstrate the iconv_strlen() function. In this program, we will find the length of Chinese chracter and Russian language character. PHP <?php // String with non-ASCII characters (Chinese) $str1 = "你好,世界!"; // "Hello, World!" in Chinese // String with non-ASCII characters (Russian) $str2 = "Привет, мир!"; // "Hello, World!" in Russian // Calculate lengths using iconv_strlen() $length1 = iconv_strlen($str1); $length2 = iconv_strlen($str2); // Output the lengths echo "Length of '$str1': $length1\n"; echo "Length of '$str2': $length2\n"; ?> OutputLength of '你好,世界!': 6 Length of 'Привет, мир!': 12 Comment More infoAdvertise with us Next Article PHP iconv_strlen() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-Questions Similar Reads PHP iconv_substr() Function The icnov_substr() is an inbuilt function in PHP that allows you to extract a portion of a string based on a specified character encoding. Syntax: iconv_substr( string $string, int $offset, ?int $length = null, ?string $encoding = null ): string|falseParameters: This function takes four parameters t 2 min read PHP strlen() Function The strlen() is a built-in function in PHP which returns the length of a given string.It calculates the length of the string including all the whitespaces and special characters. Syntax:strlen($string);Parameters: This parameter represents the string whose length is needed to be returned. Return Val 1 min read PHP iconv_strrpos() Function The iconv_strrpos() function is an inbuilt function in PHP that searches for the last occurrence of a substring within a string while taking the character encoding of the string into account. It is similar to the strrpos() function, but it supports multi-byte character sets. Syntax: int|false iconv_ 1 min read PHP mb_strlen() Function The mb_strlen() is an inbuilt PHP function that returns the string length in an integer. Syntax: mb_strlen($string, $encoding ): intParameters: This function accepts 2 parameters that are described below: $string: The string parameter whose lengths need to be determined. It is a required parameter.$ 1 min read PHP | iconv() Function The iconv() function is an inbuilt function in PHP which is used to convert a string to requested character encoding. The iconv() is an international standard conversion application command-line programming interface which converts different character encodings to other encoding types with the help 3 min read Like