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.
RequirementsNo external libraries are needed to build this extension.
InstallationThere is no installation needed to use these functions; they are part of the PHP core.
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.
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 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 -- 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 from the beginning of a string md5_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 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 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 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 from the beginning and end of a string ucfirst -- Make a string's first character uppercaseucwords -- Uppercase the first character of each word in a string vprintf -- Output a formatted stringvsprintf -- Return a formatted stringwordwrap -- Wraps a string to a given number of characters using a string break character.
Who's Online
Guest Users: 9
Deliver First Class Web Sites: 101 Essential Checklists Want to learn how to make your web sites usable and accessible? Want to ensure that your sites meet current best practice, without spending hours trawling through incomprehensible specifications and recommendations from dozens of different books, research papers, and web sites? Want to make sure that the sites you build are "right the first time," requiring no costly redevelopments?
More Sample Chapters