FUNCTION NAME |
FUNCTION DESCRIPTION |
FUNCTION SYNTAX |
FUNCTION RETURN VALUE |
sha1()
[Calculate the sha1 hash of a string] |
This function calculates the sha1 hash of string, using the US Secure Hash Algorithm 1. |
sha1(string, raw_output [optional parameter with a default value of FALSE]);
[If raw_output is set to TRUE, the sha1 digest is instead returned in raw binary format with a length of 20; otherwise the returned value is a 40-character hexadecimal number.] |
sha1() : returns the sha1 hash as a string. |
similar_text()
[Calculate the similarity between two strings] |
This function calculates the similarity of string_1 and string_2 [two ‘texts’]. |
similar_text(string_1, string_2, percentage [optional parameter – passing a reference as the third parameter stores the similarity in percent, by dividing the result of similar_text() by the average length of the given strings (similar_text() /((string_1_length + string_2_length)/2) * 100)]);
[The number of matching characters is calculated by finding the longest first common substring, and then doing this for the prefixes and the suffixes, recursively. The lengths of all common substrings are added.] |
similar_text() : returns the number of matching chars in both strings. |
soundex()
[Calculate the soundex key of a string] |
Calculates the soundex key of string. Words pronounced similarly produce the same soundex key, and can therefore be used to simplify searching databases where you know the pronunciation but not the spelling. This implementation of the soundex function returns a string 4 characters long, starting with a letter. |
soundex(string); |
soundex() : returns the soundex key as string. |
sprintf()
[Return a formatted string] |
This function returns a string produced according to format_string. |
sprintf(format_string, args... [optional parameters that will be formatted according to format_string]);
[The format_string is composed of zero or more directives: ordinary characters that are copied directly to the result and conversion specifications, each of which results in fetching its own parameter. Each conversion specification contains a percentage sign followed by one or more of the following elements, in sequence: sign specifier; padding specifier; alignment specifier; width specifier; precision specifier; and a type specifier.] |
sprintf() : returns a string produced according to format_string on success; FALSE on failure. |
sscanf()
[Parses input from a string according to a format] |
This function reads [‘scans’] from string and interprets it according to format. Any whitespace in format [even a tab \t] matches any whitespace in string. |
sscanf(string, format, args... [optionally pass in variables by reference that will contain the parsed values]); |
sscanf() : if only two parameters were present, the values parsed will be returned as an array. If optional parameters are passed, the function will return the number of assigned values. If more substrings are expected in format than are available within string, -1 will be returned. |
str_getcsv()
[Parse a CSV string into an array] |
This function parses input_string for fields in CSV format and returns an array containing the fields read. Take care with locale settings when using this function – strings in one-byte encodings may be read incorrectly if LC_CTYPE is set to en_US.UTF-8, for example. |
str_getcsv(input_string, delimiter [optional single-character parameter, default is “,“], enclosure [optional single-character parameter, default is ‘“‘], escape_character [optional single-character parameter, default is “\“]); |
str_getcsv() : returns an indexed array containing the fields read. |
str_ireplace()
[Case-insensitive version of str_replace() ] |
This function returns a string or an array with all case-insensitive occurrences of search in subject replaced with the given replace value. |
str_ireplace(search, replace, subject, count [optional parameter – if passed, this will be set to the number of replacements performed]);
[Search and replace rules: if search and replace are arrays, a value is taken from each array and used to search-and-replace on subject; if replace has fewer values than search, an empty string is used for the rest of replacement values; if search is an array and replace is a string, then this replacement string is used for every value of search; if search or replace are arrays, their elements are processed first to last.] |
str_ireplace() : returns a string or an array of replacements. |
str_pad()
[Pad a string to a certain length with another string] |
This function returns input_string padded on the left, the right, or on both sides to the specified pad_length. If pad_string is not supplied, input_string is padded with spaces; otherwise it is padded with characters from pad_string up to the limit. |
str_pad(input_string, pad_length, pad_string [optional parameter – default is whitespace “ “], pad_type [optional parameter – default value is STR_PAD_RIGHT]);
[If pad_length is negative, less than or equal to the length of input_string, no padding takes place and input_string will be returned. The pad_string may be truncated if the required number of padding characters cannot be evenly divided by the pad_string‘s length. pad_type can be any of the following values: STR_PAD_RIGHT; STR_PAD_LEFT; or STR_PAD_BOTH] |
str_pad() : returns the padded string. |
str_repeat()
[Repeat a string] |
This function returns input_string repeated multiplier times. |
str_repeat(input_string, multiplier);
[multiplier must be greater than or equal to 0. If 0, an empty string will be returned.] |
str_repeat() : returns input_string repeated multiplier times. |
str_replace()
[Replace all occurrences of the search string with the replacement string] |
This function returns a string or an array with all case-sensitive occurrences of search in subject replaced with the given replace value. |
str_replace(search, replace, subject, count [optional parameter – if present, it will be set to the number of replacements performed]);
[The same search-and-replace rules apply for this function as for str_ireplace() . Like str_ireplace() , if subject is an array then the search-and-replace is performed with every entry of subject, and the return value is an array as well.] |
str_replace() : returns a string or an array with the replaced values. |
str_rot13()
[Perform the rot13 transform on a string] |
This function performs the ROT13 encoding on string and returns the resulting string. The ROT13 encoding simply shifts every letter by 13 places in the alphabet; non-alpha characters are left untouched. Since encoding and decoding are done by the same function, passing an encoded string as argument will return the original version. |
str_rot13(string); |
str_rot13() : returns the ROT13 version of string. |
Leave a Reply