String Functions CLI. String Functions
These functions all manipulate strings in various ways. Some more
specialized sections can be found in the regular expression and
URL handling sections.
For information on how strings behave, especially with regard to
usage of single quotes, double quotes, and escape sequences, see
the Strings entry in
the Types section of the
manual.
No external libraries are needed to build this extension.
There is no installation needed to use these
functions; they are part of the PHP core.
The constants below are defined by this extension, and
will only be available when the extension has either
been compiled into PHP or dynamically loaded at runtime.
Table of Contents addcslashes -- Quote string with slashes in a C styleaddslashes -- Quote string with slashesbin2hex --
Convert binary data into hexadecimal representation
chop -- Alias of rtrim() chr -- Return a specific characterchunk_split -- Split a string into smaller chunksconvert_cyr_string --
Convert from one Cyrillic character set to another
convert_uudecode --
Decode a uuencoded string
convert_uuencode --
Uuencode a string
count_chars --
Return information about characters used in a string
crc32 -- Calculates the crc32 polynomial of a stringcrypt -- One-way string encryption (hashing)echo -- Output one or more stringsexplode -- Split a string by stringfprintf -- Write a formatted string to a streamget_html_translation_table --
Returns the translation table used by
htmlspecialchars() and
htmlentities()
hebrev --
Convert logical Hebrew text to visual text
hebrevc --
Convert logical Hebrew text to visual text with newline conversion
html_entity_decode --
Convert all HTML entities to their applicable characters
htmlentities --
Convert all applicable characters to HTML entities
htmlspecialchars_decode --
Convert special HTML entities back to characters
htmlspecialchars --
Convert special characters to HTML entities
implode -- Join array elements with a stringjoin -- Alias of implode() levenshtein --
Calculate Levenshtein distance between two strings
localeconv -- Get numeric formatting informationltrim --
Strip whitespace (or other characters) from the beginning of a string
md5_file -- Calculates the md5 hash of a given filemd5 -- Calculate the md5 hash of a stringmetaphone -- Calculate the metaphone key of a stringmoney_format -- Formats a number as a currency stringnl_langinfo --
Query language and locale information
nl2br --
Inserts HTML line breaks before all newlines in a string
number_format -- Format a number with grouped thousandsord -- Return ASCII value of characterparse_str -- Parses the string into variablesprint -- Output a stringprintf -- Output a formatted stringquoted_printable_decode --
Convert a quoted-printable string to an 8 bit string
quotemeta -- Quote meta charactersrtrim --
Strip whitespace (or other characters) from the end of a string
setlocale -- Set locale informationsha1_file -- Calculate the sha1 hash of a filesha1 -- Calculate the sha1 hash of a stringsimilar_text --
Calculate the similarity between two strings
soundex -- Calculate the soundex key of a stringsprintf -- Return a formatted stringsscanf --
Parses input from a string according to a format
str_ireplace --
Case-insensitive version of str_replace() .
str_pad --
Pad a string to a certain length with another string
str_repeat -- Repeat a stringstr_replace --
Replace all occurrences of the search string with the replacement string
str_rot13 -- Perform the rot13 transform on a stringstr_shuffle -- Randomly shuffles a stringstr_split --
Convert a string to an array
str_word_count --
Return information about words used in a string
strcasecmp --
Binary safe case-insensitive string comparison
strchr -- Alias of strstr() strcmp -- Binary safe string comparisonstrcoll -- Locale based string comparisonstrcspn --
Find length of initial segment not matching mask
strip_tags -- Strip HTML and PHP tags from a stringstripcslashes --
Un-quote string quoted with addcslashes()
stripos --
Find position of first occurrence of a case-insensitive string
stripslashes --
Un-quote string quoted with addslashes()
stristr --
Case-insensitive strstr()
strlen -- Get string lengthstrnatcasecmp --
Case insensitive string comparisons using a "natural order"
algorithm
strnatcmp --
String comparisons using a "natural order" algorithm
strncasecmp --
Binary safe case-insensitive string comparison of the first n
characters
strncmp --
Binary safe string comparison of the first n characters
strpbrk --
Search a string for any of a set of characters
strpos --
Find position of first occurrence of a string
strrchr --
Find the last occurrence of a character in a string
strrev -- Reverse a stringstrripos --
Find position of last occurrence of a case-insensitive string in a string
strrpos --
Find position of last occurrence of a char in a string
strspn --
Find length of initial segment matching mask
strstr -- Find first occurrence of a stringstrtok -- Tokenize stringstrtolower -- Make a string lowercasestrtoupper -- Make a string uppercasestrtr -- Translate certain characterssubstr_compare --
Binary safe optionally case insensitive comparison of 2 strings from an offset, up to length characters
substr_count -- Count the number of substring occurrencessubstr_replace -- Replace text within a portion of a stringsubstr -- Return part of a stringtrim -- Strip whitespace (or other characters) from the beginning and end of a stringucfirst -- Make a string's first character uppercaseucwords --
Uppercase the first character of each word in a string
vfprintf -- Write a formatted string to a streamvprintf -- Output a formatted stringvsprintf -- Return a formatted stringwordwrap --
Wraps a string to a given number of characters using a string
break character
Links
Aplus.net $7.46/mo 170GB Diskspace 2000GB Bandwidth PHP Perl Ruby C/C++ Python TCL SSI CGI 2 Free Domain Names DNS Management 99.99% Uptime IX Web Hosting $6.45/mo 400GB Diskspace 2500GB Bandwidth Host 8 Domains PHP Perl CGI SSI MySQL PostgreSQL 3 Free Domain For Life Additional costs for Windows plan + $2.50:ASP/.NET, Cold Fusion, ODBC/DSN, MSSQL HostGator $9.95/mo 100GB Diskspace 1000GB Bandwidth Host Unlimited Domains CPanel PHP CGI SSH SSI Instant Backups 99.9% Uptime Guarantee 30 Day Money Back
Partners