Reference to the search-and-replace functions of PHP, including Regular Expressions.
Function | Returns | Does what |
---|---|---|
ltrim(string [, charlist]) | String | Removes whitespace from left side of "string" |
rtrim(string [, charlist]) | String | Removes whitespace from right side of "string" |
trim(string [, charlist]) | String | Removes whitespace from both sides of "string" |
chr(ascii) | String | Returns character for Ascii code |
ord(string) | Integer | Returns Ascii code for first character of "string" |
str_pad(string, new_length [, pad_string [, pad_type]]) | String | Pads "string" to "new_length" using "pad_string" |
str_repeat(string, multiplier) | String | Repeats "string" "multiplier" times |
str_replace(pattern, new_pattern, string [, count]) | String | Replaces "pattern" with "new_pattern" in "string" |
str_ireplace(pattern, new_pattern, string [, count]) | String | Replaces "pattern" with "new_pattern" in "string". Case insensitive |
strstr(string, pattern [, before_pattern]) | String | Returns first ocurrence of "pattern" in "string" |
stristr(string, pattern [, before_pattern]) | String | Returns first ocurrence of "pattern" in "string". Case insensitive. |
strcspn(string, pattern [, start [, length]]) | Integer | Returns no. of chars at start of "string" without match in "pattern" |
strspn(string, pattern [, start [, length]]) | Integer | Returns no. of chars at start of "string" matching "pattern" |
strpos(string, pattern [, offset]) | Integer | Returns position of first "pattern" in "string" |
stripos(string, pattern [, offset]) | Integer | Returns position of first "pattern" in "string". Case insensitive. |
strrpos(string, pattern [, offset]) | Integer | Returns position of last "pattern" in "string" |
strripos(string, pattern [, offset]) | Integer | Returns position of last "pattern" in "string". Case insensitive. |
strrchr(string, pattern) | String | Returns end of "string" from last "pattern" to end |
strrev(string) | String | Returns "string" in reverse order |
strtok(string, separator) | String | Breaks "string" into segments, separated by "separator" |
strtr(string, pattern, replacement) | String | Replaces "pattern" with "replacement" in "string" |
substr(string, start [, length]) | String | Returns "length" characters from "start" of "string" |
substr_count(string, pattern [, offset [, length]]) | Integer | Counts no. of times "pattern" is in "string" |
substr_replace(string, replacement, start [, length]) | Mixed | Replaces text in "string" with "replacement", from "start" |
str_shuffle(string) | String | Shuffles characters in "string" |
Function | Returns | Does what |
---|---|---|
substr_compare(string1, string2 [, offset [, length [, no_case]]]) | Integer | Binary safe comparison of two strings. From "offset", up to "length" characters. Default case sensitive |
strcasecmp(string1, string2) | Integer | Binary safe string comparison. Case insensitive. |
strcmp(string1, string2) | Integer | Binary safe string comparison. Case sensitive. |
strcoll(string1, string2) | Integer | Locale based string comparison. Not binary safe, case sensitive. |
levenshtein(string1, string2) | Integer | Returns Levenshtein Distance between two texts |
similar_text(string1, string2 [, percent]) | Integer | Returns a string similarity measure |
strncasecmp(string1, string2, length) | Integer | Binary safe string comparison of the first "length" characters. Case-insensitive |
strncmp(string1, string2, length) | Integer | Binary safe string comparison of the first "length" characters. |
strnatcasecmp(string1, string2) | Integer | Compares using "natural order" algorithm. Case-insensitive |
strnatcmp(string1, string2) | Integer | Compares using "natural order" algorithm. |
Function | Returns | Does what |
---|---|---|
crc32(string) | Integer | Returns cyclic redundancy checksum of "string" |
md5(string [, raw_out]) | String | Returns MD5 hash of "string" |
hash(algorithm, string [, raw_out]) | String | Returns hash of "string" using "algorithm" ("md5", "sha256", ...) |
metaphone(string [, phonemes]) | String | Returns Metaphone Key of "string" (similar sound = same key) |
soundex(string) | String | Returns Soundex Key of "string" (similar sound = same key) |
strlen(string) | Integer | Returns length of "string" |
str_word_count(string [, format [, charlist]]) | Mixed | Returns no. of words in "string" |
count_chars(string [, mode]) | Mixed | Returns no. of characters in "string" |
Function | Returns | Does what |
---|---|---|
Ereg(regexp, string [, result]) | Integer | Searches "string" for "regexp", stores result in "result" |
ereg_replace(regexp, new_regexp, string) | String | Replaces "regexp" with "new_regexp", in "string" |
Eregi(regexp, string [, result]) | Integer | Searches "string" for "regexp", stores result in "result". Case insensitive. |
eregi_replace(regexp, new_regexp, string) | String | Replaces "regexp" with "new_regexp", in "string". Case insensitive. |
Split(regexp, string [, limit]) | Array | Splits "string", according to "regexp" |
Spliti(regexp, string [, limit]) | Array | Splits "string", according to "regexp". Case insensitive. |
sql_regcase(string) | RegExp | Retuns a (case-insensitive) RegExp matching "string" |
Function | Returns | Does what |
---|---|---|
preg_filter(regexp, new_regexp, string [, limit [, count]]) | Mixed | Replaces "regexp" with "new_regexp", in "string" |
preg_grep(regexp, string [, flags]) | Array | Returns items in "string" matching "regexp" |
preg_last_error() | Integer | Shows last regexp error |
preg_match(regexp, string [, result [, flags [, offset]]]) | Integer | Searches "string" for "regexp", stores result in "result" |
preg_match_all(regexp, string, result [, order [, flags [, offset]]]) | Integer | Searches "string" for "regexp", stores result in "result", ordered by "order". Global search. |
preg_quote(string [, delimiter]) | String | Escapes regexp chars in "string", adds "delimiter" |
preg_replace(regexp, new_regexp, string [, limit [, count]]) | Mixed | Replaces "regexp" with "new_regexp", in "string" |
preg_replace_callback(regexp, callback, string [, limit [, count]]) | Mixed | Finds "regexp" in "string", does "callback" |
preg_split(regexp, string [, limit [, flags]]) | Array | Splits "string", according to "regexp" |
More: