PHP count_chars()function4 Sept 2024 | 2 min read PHP count_chars() is most important string function. It is used to return information about characters in a string. Syntax:
Note: Depending on mode 'count_chars()' function returns one of the following:
Example 1Output: Your given string: Hello World! By using 'count_chars()' function your string is : !HWdelor Example 2Output: Array ( [32] => 1 [33] => 1 [72] => 1 [87] => 1 [100] => 1 [101] => 1 [108] => 3 [111] => 2 [114] => 1 ) Example 3Output: The character ' ' was found 3 time(s) The character '!' was found 1 time(s) The character 'H' was found 1 time(s) The character 'L' was found 2 time(s) The character 'P' was found 2 time(s) The character 'a' was found 2 time(s) The character 'e' was found 2 time(s) The character 'g' was found 2 time(s) The character 'i' was found 1 time(s) The character 'l' was found 1 time(s) The character 'n' was found 1 time(s) The character 'o' was found 1 time(s) The character 's' was found 1 time(s) The character 'u' was found 1 time(s) The character 'v' was found 1 time(s) The character 'y' was found 1 time(s) Next TopicPHP String |
PHP string Function PHP is predefined function which is used to remove whitespace or character form the right side of a string. Syntax: rtrim(string,charlist); Parameter Description Required/Optional string Specify the string to check. required charlist Specify character to remove Following character "\0" - NULL "\t" - tab "\n" - new line "\x0B" - vertical tab "\r" - carriage return " "...
1 min read
PHP String Function The function is used to convert the first character of the string into the uppercase. It is an in-built function of PHP, which takes a string as input and converts only the first letter of that string to uppercase. This function converts...
2 min read
PHP String function The is an in-built function of PHP, which is used to replace a substring inside the other string. It provides the facility to change the particular word in a string. The function translates characters or replaces the substrings. It is a...
3 min read
PHP string Function PHP string function predefined functions. It is used to output a formatted string. We can pass the arg1, arg2, arg++ parameters at percent (%) signs in the main string. Syntax: printf(format,arg1,arg2,arg++); Parameter Description Required/Optional format Specify the string. Following are the possible format values: %% - Returns a percent sign %b...
1 min read
PHP String Function The is predefined PHP function. It is used to return parses input from a string according to a format. If we will pass two parameters in the function, the data will be returned as an array. Related Function: print(): It is used for output...
1 min read
PHP String function The is one of the most popular functions of PHP, which is widely used to convert the string into lowercase. It takes a string as a parameter and converts all uppercase English character of that string to lowercase. Other characters such as...
2 min read
PHP string levenshtein() Function PHP string levenshtein() function is in-built function. It is used to calculate the distance between two strings. By default, PHP provides some operations (replace, insert and delete) It returns the Levenshtein distance between the two argument strings or -1, if the string exceeds 255...
1 min read
String Function The is the in-built function of PHP. This function returns the translation table which is used by htmlspecialchars() and htmlentities() functions. There are several ways to encode the special characters. E.g. ", ", or &#34. Syntax get_html_translation_table(table, flags, encoding) For example get_html_translation_table( [ int $table = HTML_SPECIALCHARS...
2 min read
PHP str_replace() function The str_replace() function is a case-sensitive, built-in function of PHP which replaces some character of the string with other characters. It is used to replace all the occurrences of the search string with the replacement string. Syntax The syntax of the str_replace() function is given below,...
3 min read
PHP Function The function is used to remove whitespace or other predefined character from the right end of a string. Syntax: chop(string,charlist); Note: function is different than the Perl function function, which is used to remove the last character in the string. Parameter Description Required/Optional string the string to be check Required charlist charlist...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India