Useful String Functions

Can be found at: PHP Manual -- String Functions


addslashes -- Adds escape slashes to a string

stripslashes -- Removes escape slashes from a string

bin2hex -- Converts binary data into hexadecimal

chr -- Returns a specific character (i.e., 65 = "A")

ord -- Returns ASCII value of character (i.e., "A" = 65)

count_chars -- Returns an array with what ASCII characters were found in a string

echo -- Outputs strings to the screen

print -- Outputs a string to the screen

printf -- Outputs a formatted string

sprintf -- Returns a formatted string

explode -- Splits a string into an array using a delimiter

implode -- Joins array elements into a single string

join -- Alias of implode()

fprintf -- Writes a formatted string to a stream

htmlentities -- Converts all applicable characters to HTML entities

html_entity_decode -- Converts all HTML entities to their applicable characters

htmlspecialchars -- Converts special characters to HTML entities

htmlspecialchars_decode -- Converts special HTML entities back to characters

levenshtein -- Calculates the Levenshtein distance between two strings

metaphone -- Calculate the metaphone key of a string

similar_text -- Calculate the similarity between two strings

soundex -- Calculate the soundex key of a string

localeconv -- Get local numeric formatting information

trim -- Strips whitespace (or other characters) from the beginning and end of a string

ltrim -- Strips whitespace (or other characters) from the beginning of a string

rtrim -- Stris whitespace (or other characters) from the end of a string

chop -- Alias of rtrim()

md5_file -- Calculates the md5 hash of a given file

md5 -- Calculates the md5 hash of a string

crypt -- One-way string encryption (i.e., hashing)

money_format -- Formats a number as a currency string

nl2br -- Inserts HTML line breaks (i.e., <br>) before all newlines in a string

number_format -- Format a number with grouped thousands

parse_str -- Parses the string into variables

setlocale -- Sets locale information

str_getcsv -- Parses a CSV string into an array

str_pad -- Pads a string to a certain length with another string

str_repeat -- Repeats a string

str_replace -- Replaces all occurrences of the search string with the replacement string

str_ireplace -- Case-insensitive version of str_replace().

str_rot13 -- Performs the rot13 transform on a string

str_shuffle -- Randomly shuffles a string

str_split -- Converts a string to an array

str_word_count -- Returns information about words used in a string

strcasecmp -- Binary safe case-insensitive string comparison

strchr -- Alias of strstr()

strcmp -- Binary safe string comparison

strcoll -- Locale based string comparison

strcspn -- Find length of initial segment not matching mask

strip_tags -- Strip HTML and PHP tags from a string

stripcslashes -- Un-quote string quoted with addcslashes()

stripos -- Finds position of first occurrence of a case-insensitive string

stristr -- Case-insensitive strstr()

strlen -- Get string length

strnatcasecmp -- 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 -- Searches a string for any of a set of characters

strpos -- Finds position of first occurrence of a string

strrchr -- Finds the last occurrence of a character in a string

strrev -- Reverses a string

strripos -- Finds position of last occurrence of a case-insensitive string in a string

strrpos -- Finds position of last occurrence of a char in a string

strspn -- Finds length of initial segment matching mask

strstr -- Finds first occurrence of a string

strtok -- Tokenizes string

strtolower -- Makes a string lowercase

strtoupper -- Makes a string uppercase

strtr -- Translatse certain characters

substr_compare -- Binary safe optionally case insensitive comparison of 2 strings from an offset, up to length characters

substr_count -- Counts the number of substring occurrences

substr_replace -- Replaces text within a portion of a string

substr -- Returns part of a string

ucfirst -- Make a string's first character uppercase

ucwords -- Uppercase the first character of each word in a string

wordwrap -- Wraps a string to a given number of characters using a string break character