DJ Mike's Tutorials: PHP


< ^ >

String Functions

addcslashes()
Quote string with slashes in a C style
addslashes()
Quote string with slashes
bin2hex
Convert binary data into hexadecimal representation.
chop
Alias of: rtrim().
chr
Return a specific character
chunk_split()
Split a string into smaller chunks
convert_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 string.
crypt()
One-way string encryption (hashing)
echo
Output one or more strings
ereg()
Searches a string for matches to the regular expression. Case-sensitive.
Format: ereg("regex", $string);
eregi()
Searches a string for matches to the regular expression. Case-insensitive.
Format: eregi("regex", $string);
explode()
Split a string by string
fprintf()
Write a formatted string to a stream
get_html_translation_table
Returns the translation table that is used internally for htmlspecialchars() and htmlentities().
htmlentities()
Convert all applicable characters to HTML entities
hebrev()
Convert logical Hebrew text to visual text
hebrevc()
Convert logical Hebrew text to visual text with newline conversion
highlight_string()
Colors HTML & PHP code by syntax. Show Example | Show Code | Hide
html_entity_decode()
Convert all HTML entities to their applicable characters.
htmlspecialchars_decode()
Convert special HTML entities back to characters
htmlspecialchars()
Convert special characters to HTML entities
implode()
Join array elements with a string
join()
Alias of implode
lcfirst()
Make a string's first character lowercase
lcfirst()
levenshtein
Calculate Levenshtein distance between two strings
levenshtein()
localeconv
Get numeric formatting information
ltrim
Strip whitespace (or other characters) from the beginning of a string
md5_file()
Calculates the md5 hash of a given file
md5()
Calculate the md5 hash of a string
metaphone()
Calculate the metaphone key of a string
money_format()
Formats a number as a currency string
nl_langinfo()
Query language and locale information
nl2br()
Replaces new lines with the HTML tag, <br />
Show Example | Show Code | Hide
number_format
Format a number with grouped thousands
ord
Return ASCII value of character
ord()
parse_str()
Parses the string into variables
parse_url()
Accepts a string representing a URL and returns the components as an associative array. This includes the
Show Example | Show Code | Hide
print
Output a string
printf()
Output a formatted string
quoted_printable_decode
Convert a quoted-printable string to an 8 bit string
quoted_printable_decode()
quotemeta()
Quote meta characters
rtrim()
Strip whitespace (or other characters) from the end of a string
setlocale()
Set locale information
sha1_file
Calculate the sha1 hash of a file
sha1
Calculate the sha1 hash of a string
similar_text
Calculate the similarity between two strings
soundex
Calculate the soundex key of a string
sprintf
Return a formatted string
sscanf
Parses input from a string according to a format
str_getcsv()
Parse a CSV string into an array
str_ireplace()
Case-insensitive version of str_replace.
str_pad()
Pad a string to a certain length with another string
str_repeat()
Repeats a string a specified number of times
Show Example | Show Code | Hide
str_replace()
Replaces all occurances of a string within a larger string with another string. Case sensitive.
Show Example | Show Code | Hide
str_rot13
Perform the rot13 transform on a string
str_shuffle
Randomly shuffles a string
str_split
Convert a string to an array
str_split()
str_word_count
Return information about words used in a string
str_word_count()
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()
Removes HTML and PHP tags from a string. Has an optional field where allowed tags that should not be stripped,
Show Example | Show Code | Hide
stripcslashes()
Un-quote string quoted with addcslashes
stripos
Find position of first occurrence of a case-insensitive string
stripslashes()
When HTML is entered into a form, quotes are automaticly escaped with backslashes. To un-do that, use stripslashes() before the string is outputed.
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
Search a string for any of a set of characters
strlen()
Show the number of characters in a string
Show Example | Show Code | Hide
strstr()
Find first occurrence of a string
strpos()
Find position of first occurrence of a string
strrchr()
Find the last occurrence of a character in a string
strrev
Reverse a string
strripos()
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
strtok()
Tokenize string
strtolower()
Converts all upper case characters to lower case
Show Example | Show Code | Hide
strtoupper
Converts all lower case characters to upper case
Show Example | Show Code | Hide
strtr()
Translate certain characters
substr_compare()
Binary safe comparison of 2 strings from an offset, up to length characters
substr_count()
Count the number of substring occurrences
substr_replace
Replace text within a portion of a string
substr()
Finds a substring in $string starting from start and reading number characters
Format: $substring = substr($string, start, number);
trim
Strip whitespace (or other characters) from the beginning and end of a string
ucfirst
Make a string's first character uppercase
ucwords()
Capitalizes the first letter of every word
Show Example | Show Code | Hide
trim()
Strips whitespace (or other characters) from the beginning and end of a string. Whitespace include
Format: $out = trim($in);
Has an optional parameter that specifies other characters to remove.
Format: $out = trim($in, "ab");
In the example above, the letters a and b will be removed along with white spaces if they are leading or trailing characters. With .., you can specify a range of characters to be removed.
Format: $out = trim($in, "a..n");
In the example above, the letters a through n will be removed along with white spaces if they are leading or trailing characters.
vfprintf()
Write a formatted string to a stream
vprintf()
Output a formatted string
vsprintf()
Return a formatted string
wordwrap()
Wraps a string to a given number of characters

< ^ >



Created by DJ Mike from Santa Barbara

DJ Mike


Dance Away Santa Barbara's Home Page
<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>