CVI. String Functions
Introduction
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.
Predefined Constants
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.
CRYPT_SALT_LENGTH
integer
CRYPT_STD_DES integer
CRYPT_EXT_DES integer
CRYPT_MD5 integer
CRYPT_BLOWFISH integer
HTML_SPECIALCHARS ( integer)
HTML_ENTITIES ( integer)
ENT_COMPAT ( integer)
ENT_QUOTES ( integer)
ENT_NOQUOTES ( integer)
CHAR_MAX ( integer)
LC_CTYPE ( integer)
LC_NUMERIC ( integer)
LC_TIME ( integer)
LC_COLLATE ( integer)
LC_MONETARY ( integer)
LC_ALL ( integer)
LC_MESSAGES ( integer)
STR_PAD_LEFT ( integer)
STR_PAD_RIGHT ( integer)
STR_PAD_BOTH ( integer)
See Also
For even more powerful string handling and manipulating functions take a look at the POSIX regular expression functions and the Perl compatible regular expression functions.
Table of Contents
addcslashes -- Quote string with slashes in a C styleaddslashes -- Quote string with slashesbin2hex -- Convert binary data into hexadecimal representationchop -- Alias of
rtrim()
chr -- Return a specific characterchunk_split -- Split a string into smaller chunksconvert_cyr_string -- Convert from one Cyrillic character set to anothercount_chars -- Return information about characters used in a stringcrc32 -- 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 texthebrevc -- Convert logical Hebrew text to visual text with newline conversionhtml_entity_decode -- Convert all HTML entities to their applicable charactershtmlentities -- Convert all applicable characters to HTML entitieshtmlspecialchars -- Convert special characters to HTML entitiesimplode -- Join array elements with a stringjoin -- Alias of
implode()
levenshtein -- Calculate Levenshtein distance between two stringslocaleconv -- Get numeric formatting informationltrim -- Strip whitespace from the beginning of a stringmd5_file -- Calculates the md5 hash of a given filenamemd5 -- 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 informationnl2br -- Inserts HTML line breaks before all newlines in a stringnumber_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 stringquotemeta -- Quote meta charactersrtrim -- Strip whitespace from the end of a stringsetlocale -- Set locale informationsha1_file -- Calculate the sha1 hash of a filesha1 -- Calculate the sha1 hash of a stringsimilar_text -- Calculate the similarity between two stringssoundex -- Calculate the soundex key of a stringsprintf -- Return a formatted stringsscanf -- Parses input from a string according to a formatstr_ireplace -- Case-insensitive version of
str_replace().str_pad -- Pad a string to a certain length with another stringstr_repeat -- Repeat a stringstr_replace -- Replace all occurrences of the search string with the replacement stringstr_rot13 -- Perform the rot13 transform on a stringstr_shuffle -- Randomly shuffles a stringstr_split -- Convert a string to an arraystr_word_count -- Return information about words used in a stringstrcasecmp -- Binary safe case-insensitive string comparisonstrchr -- Alias of
strstr()
strcmp -- Binary safe string comparisonstrcoll -- Locale based string comparisonstrcspn -- Find length of initial segment not matching maskstrip_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 stringstripslashes -- Un-quote string quoted with
addslashes()stristr -- Case-insensitive
strstr()strlen -- Get string lengthstrnatcasecmp -- Case insensitive string comparisons using a "natural order" algorithmstrnatcmp -- String comparisons using a "natural order" algorithmstrncasecmp -- Binary safe case-insensitive string comparison of the first n charactersstrncmp -- Binary safe string comparison of the first n charactersstrpos -- Find position of first occurrence of a stringstrrchr -- Find the last occurrence of a character in a stringstrrev -- Reverse a stringstrripos -- Find position of last occurrence of a case-insensitive string in a stringstrrpos -- Find position of last occurrence of a char in a stringstrspn -- Find length of initial segment matching maskstrstr -- 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 characterssubstr_count -- Count the number of substring occurrencessubstr_replace -- Replace text within a portion of a stringsubstr -- Return part of a stringtrim -- Strip whitespace from the beginning and end of a stringucfirst -- Make a string's first character uppercaseucwords -- Uppercase the first character of each word in a stringvprintf -- Output a formatted stringvsprintf -- Return a formatted stringwordwrap -- Wraps a string to a given number of characters using a string break character.



