PHP iconv_substr() Function Last Updated : 10 May, 2023 Comments Improve Suggest changes Like Article Like Report 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 that are described below. $string: The input string from which you want to extract a portion.$offset: The position of the first character to extract. The position is zero-based, meaning the first character is at position 0, the second character is at position 1, and so on.$length: The length of the portion you want to extract. If this value is negative, the function extracts everything from the start position to the end of the string.$ecoding: The character encoding used in the input string.Return Values: The return value of iconv_substr() is the extracted portion of the string, or false if the length of the string is less than the offset characters long. In the case when the string's length is the same as the offset characters long, then the empty string will be returned. Example 1: The following program demonstrates the iconv_substr() function. PHP <?php $string = "Hello123"; $portion = iconv_substr($string, 2, 3, "UTF-8"); echo $portion; ?> Output: llo Example 2: The following program demonstrates the iconv_substr() function. PHP <?php $string = "1a2b3c4d5e"; $portion = iconv_substr($string, -3, 3, "UTF-8"); echo $portion; ?> Output: d5e Reference: https://www.php.net/manual/en/function.iconv-substr.php Comment More infoAdvertise with us Next Article PHP iconv_substr() Function neeraj3304 Follow Improve Article Tags : PHP Similar Reads PHP iconv_strlen() Function 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 $en 2 min read PHP substr() function The substr() is a built-in function in PHP that is used to extract a part of string. Syntax: substr(string_name, start_position, string_length_to_cut) Parameters: The substr() function allows 3 parameters or arguments out of which two are mandatory and one is optional. string_name: In this parameter 2 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_strstr() Function The mb_strstr() function is an inbuilt function in PHP that finds the first occurrence of a given string in the main string, i.e. it will search for the occurrence of the first needle in haystack, & id found then the portion of the haystack will be returned, otherwise return false. Syntax: mb_st 2 min read PHP strstr() Function The strstr() function is a built-in function in PHP. It searches for the first occurrence of a string inside another string and displays the portion of the latter starting from the first occurrence of the former in the latter (before if specified). This function is case-sensitive. Syntax : strstr( $ 2 min read PHP substr_count() Function The substr_count() is a built-in function in PHP and is used to count the number of times a substring occurs in a given string. The function also provides us with an option to search for the given substring in a given range of the index. It is case sensitive, i.e., "abc" substring is not present in 3 min read PHP stristr() Function The stristr() function is a built-in function in PHP. It searches for the first occurrence of a string inside another string and displays the portion of the latter starting from the first occurrence of the former in the latter (before if specified). This function is case-insensitive. Syntax : strist 2 min read PHP | str_ireplace() Function The str_ireplace() is a built-in function in PHP and is used to replace all the occurrences of the search string or array of search strings by replacement string or array of replacement strings in the given string or array respectively. This function performs the search in a case-insensitive manner. 3 min read PHP mb_substr_count() Function The  mb_substr_count() function is an inbuilt function in PHP that counts the occurrence of strings within a given string. Syntax: mb_substr_count($haystack, $needle, $encoding): intParameters: This function accepts three parameters that are described below: $haystack: This is the main parameter wh 1 min read PHP mb_stristr() Function The mb_stristr() is an inbuilt function in PHP that is used to get the first occurrence of a string within another string. It will check case insensitivity. Syntax:mb_stristr( $haystack, $needle, $before_needle, $encoding = null ): string|falseParameters: This function accepts 4 parameters that are 2 min read Like