English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP String String Functions

PHP string functions are part of the core. This function can be used without installation

Function List

Version-Represents the earliest version of PHP that supports this function.

NumberFunction
Description
Version
1addcslashes()Return a string with backslashes added before specified characters.4
2addslashes()Return a string with backslashes added before predefined characters.4
3bin2hex()Convert a string of ASCII characters to a hexadecimal value.4
4chop()Remove whitespace characters or other characters from the right side of a string.4
5chr()Return a character from a specified ASCII value.4
6chunk_split()Split a string into a series of smaller parts.5
7convert_cyr_string()Convert a string from one Cyrillic character set to another.4
8convert_uudecode()Decode strings encoded with uuencode.5
9count_chars()used to return information about the characters used in the string4
10crc32()Calculate a string's 32 Bit CRC (Cyclic Redundancy Check).4
11crypt()It is used to hash a string, a one-way string encryption method.4
12echo()Outputs one or more strings.4
13explode()It is used to split a string by a specified character and form an array.4
14fprintf()Used to write a formatted string to a stream5
15get_html_translation_table()It returns the conversion table used by htmlspecialchars() and htmlentities()4
16hebrev()Converts Hebrew (Hebrew) text to visible text.4
17hebrevc()Converts Hebrew (Hebrew) text to visible text, and converts new lines (\n) to <br>.4
18hex2bin()Used to convert hexadecimal strings to ASCII characters4
19html_entity_decode()Used to convert HTML entities to characters.4
20htmlentities()It is used to convert characters to HTML entities.5.4
21htmlspecialchars_decode()Converts some predefined HTML entities to characters.5.1.0
22htmlspecialchars()Converts some predefined characters to HTML entities.4
23implode()It is used to concatenate array elements with a string5
24join()It is an alias for implode(), which returns a string from the elements of an array4
25lcfirst()It is used to convert the first character of a string to lowercase.5.3.0
26levenshtein()Returns the Levenshtein distance between two strings.4.0.1
27localeconv()Returns local number and currency format information.4
28ltrim()It is used to remove spaces or other characters from the beginning of a string4
29md5_file()Used to calculate the md of a given file5 Hashing4
30md5()Used to calculate the md of a string5 Hashing4
31metaphone()Calculates the metaphone key of a string.4
32money_format()Used to format numbers into currency strings4.3.0
33nl_langinfo()It contains information about the language and language environment4.3.0
34nl2br()Inserts an HTML newline character before each new line in the string.4
35number_format()Formats numbers by grouping in thousands.4
36ord()Returns the ASCII value of the first character in the string.4
37parse_str()It is used to parse a string into a variable4
38print()Returns a string output4
39printf()Returns a formatted string4
40mb_substr()Cut a specified length of characters from a string, often used for Chinese truncation, which can avoid乱码when truncating, that is, truncating half a character.4
41quoted_printable_decode()Used to convert a quoted printable string to8bit string4
42quoted_printable_encode()Used to convert8Convert a bit string to a quoted printable string4
43quotemeta()It is used to quote metacharacters4
44rtrim()Remove whitespace characters or other characters from the right side of a string.4
45setlocale()Used to set locale information4
46sha1_file()Calculate the SHA of a file-1 Hashing.
4
47sha1()Calculate the SHA of a string-1 Hashing.4
48similar_text()Used to calculate the similarity between two strings4
49soundex()Calculate the soundex key of a string.
4
50sprintf()It is used to format a string4
51str_getcsv()It is used to parse a CSV string into an array4
52str_ireplace()Replace some characters in the string (case-insensitive).5
53str_pad()It is used to pad a string to a new length.4.0.1
54str_repeat()Used to repeat a string a specified number of times.4
55str_replace()Replace some characters in the replacement string (case-insensitive).4
56str_rot13()Execute ROT on a string.13 Encoding.4
57str_shuffle()Randomly shuffle all characters in a string.4.3.0
58str_split()Split a string into an array.5
59str_word_count()Calculate the number of words in a string.5
60strcasecmp()Used to compare two strings (case-insensitive).4
61strchr()Find the first occurrence of a string in another string. (Alias of strstr()).4
62strcmp()Compare two strings (case-insensitive).4
63strcoll()Compare two strings (based on the local settings).4.0.5
64strcspn()Returns the number of characters in the string before the first occurrence of any specified character.4
65strip_tags()Remove HTML and PHP tags from a string.4
66stripcslashes()Remove backslashes added by the addcslashes() function.4
67stripos()Used to find the first occurrence of a string within another string.4
68stripslashes()Remove backslashes added by the addslashes() function.4
69stristr()Return the position of the first occurrence of a string in another string (case-insensitive).4
70strlen()It is used to get the length of a string.4
71strnatcasecmp()Compare two strings using a "natural sort" algorithm (case-insensitive).4
72strnatcmp()Compare two strings using a "natural sort" algorithm (case-sensitive).4
73strncasecmp()String comparison of the first n characters (case-insensitive).4
74strncmp()String comparison of the first n characters (case-sensitive).4
75strpbrk()Search for any specified character in a string.5
76strpos()It is used to find the first occurrence of a string in another string (case-sensitive).4
77strrchr()It is used to find the last occurrence of a character in a string.4
78strrev()Used for reversing a string.4
79strripos()Find the last occurrence of a string within another string (case-insensitive).5
80strspn()Return the number of occurrences of a specific character in a string.4
81strstr()Find the first occurrence of a string within another string (case-sensitive).4
82strtok()Split a string into smaller strings.4
83strtolower()Convert a string to lowercase letters.4
84strtoupper()Convert a string to uppercase letters.4
85strtr()Convert specific characters in a string.4
86substr_compare()It is used to compare two string formats starting from a specific position4
87substr_count()It is used to calculate the number of substrings4
88substr_replace()Replace a part of the string with another string.4
89substr()It is used to return a part of the string4
90trim()Used to remove whitespace and other characters from both sides of a string.4
91ucfirst()It is used to convert the first character of a string to uppercase4
92ucwords()Convert the first letter of each word in a string to uppercase.4
93vfprintf()Write the formatted string to the specified output stream.5
94vprintf()Output a formatted string.4.1
95vsprintf()It returns a formatted string4.1
96wordwrap()

Break the string into lines at specified length.

4.0.2
97convert_uuencode()Use uuencode to encode a string5