* @param string $string the string which length is to be calculated
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return int Returns the number of characters within the string. A multi-byte character is counted as 1.
* This function is aimed at replacing the functions strlen() and mb_strlen() for human-language strings.
@ -1224,12 +1158,15 @@ function api_strlen($string, $encoding = null)
*
* @param string $haystack the string from which to get the position of the first occurrence
* @param string $needle the string to be found
* @param int $offset (optional) The position in $haystack to start searching from. If it is omitted, searching starts from the beginning.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param int $offset (optional) The position in $haystack to start searching from. If it is omitted, searching
* starts from the beginning.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found.
* Note: The first character's position is 0, the second character position is 1, and so on.
* This function is aimed at replacing the functions strpos() and mb_strpos() for human-language strings.
* @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle
* is not found. Note: The first character's position is 0, the second character position is 1, and so
* on. This function is aimed at replacing the functions strpos() and mb_strpos() for human-language
* @param string $haystack the string from which to get the last occurrence
* @param mixed $needle the string which first character is to be found
* @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default value is FALSE.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default
* value is FALSE.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted,
* the platform character set will be used by default.
*
* @return mixed Returns the portion of $haystack, or FALSE if the first character from $needle is not found.
* Notes:
* If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character.
* If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence.
* If $before_needle is set to FALSE, the function returns all of $haystack from the first occurrence to the end.
* This function is aimed at replacing the functions strrchr() and mb_strrchr() for human-language strings.
* If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint
* if the encoding is UTF-8) of a character. If $before_needle is set to TRUE, the function returns all
* of $haystack from the beginning to the first occurrence. If $before_needle is set to FALSE, the
* function returns all of $haystack from the first occurrence to the end. This function is aimed at
* replacing the functions strrchr() and mb_strrchr() for human-language strings.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return string Returns the reversed string.
* This function is aimed at replacing the function strrev() for human-language strings.
@ -1283,12 +1224,15 @@ function api_strrev($string, $encoding = null)
*
* @param string $haystack the string from which to get the position of the last occurrence
* @param string $needle the string to be found
* @param int $offset (optional) $offset may be specified to begin searching an arbitrary position. Negative values will stop searching at an arbitrary point prior to the end of the string.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param int $offset (optional) $offset may be specified to begin searching an arbitrary position. Negative
* values will stop searching at an arbitrary point prior to the end of the string.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return mixed Returns the numeric position of the first occurrence (case insensitive) of $needle in the $haystack, or FALSE if $needle is not found.
* Note: The first character's position is 0, the second character position is 1, and so on.
* This function is aimed at replacing the functions strripos() and mb_strripos() for human-language strings.
* @return mixed Returns the numeric position of the first occurrence (case insensitive) of $needle in the $haystack,
* or FALSE if $needle is not found. Note: The first character's position is 0, the second character
* position is 1, and so on. This function is aimed at replacing the functions strripos() and
* @param string $haystack the string from which to get the position of the last occurrence
* @param string $needle the string to be found
* @param int $offset (optional) $offset may be specified to begin searching an arbitrary position. Negative values will stop searching at an arbitrary point prior to the end of the string.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param int $offset (optional) $offset may be specified to begin searching an arbitrary position. Negative
* values will stop searching at an arbitrary point prior to the end of the string.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found.
* Note: The first character's position is 0, the second character position is 1, and so on.
* This function is aimed at replacing the functions strrpos() and mb_strrpos() for human-language strings.
* @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle
* is not found. Note: The first character's position is 0, the second character position is 1, and so
* on. This function is aimed at replacing the functions strrpos() and mb_strrpos() for human-language
* @param string $haystack the string from which to get the first occurrence
* @param mixed $needle the string to be found
* @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default value is FALSE.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default
* value is FALSE.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted,
* the platform character set will be used by default.
*
* @return mixed Returns the portion of $haystack, or FALSE if $needle is not found.
* Notes:
* If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character.
* If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence of $needle.
* If $before_needle is set to FALSE, the function returns all of $haystack from the first occurrence of $needle to the end.
* This function is aimed at replacing the functions strstr() and mb_strstr() for human-language strings.
* If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint
* if the encoding is UTF-8) of a character. If $before_needle is set to TRUE, the function returns all
* of $haystack from the beginning to the first occurrence of $needle. If $before_needle is set to FALSE,
* the function returns all of $haystack from the first occurrence of $needle to the end. This function
* is aimed at replacing the functions strstr() and mb_strstr() for human-language strings.
* @param string $string the string being lowercased
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return string Returns the string with all alphabetic characters converted to lowercase.
* This function is aimed at replacing the functions strtolower() and mb_strtolower() for human-language strings.
* This function is aimed at replacing the functions strtolower() and mb_strtolower() for human-language
@ -1362,10 +1314,12 @@ function api_strtolower($string, $encoding = null)
* Makes a string uppercase.
*
* @param string $string the string being uppercased
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return string Returns the string with all alphabetic characters converted to uppercase.
* This function is aimed at replacing the functions strtoupper() and mb_strtoupper() for human-language strings.
* This function is aimed at replacing the functions strtoupper() and mb_strtoupper() for human-language
@ -1425,13 +1379,16 @@ function api_substr_count($haystack, $needle, $encoding = null)
* @param int $start The position from which replacing will begin.
* Notes:
* If $start is positive, the replacing will begin at the $start'th offset into the string.
* If $start is negative, the replacing will begin at the $start'th character from the end of the string.
* If $start is negative, the replacing will begin at the $start'th character from the end
* of the string.
* @param int $length (optional) The position where replacing will end.
* Notes:
* If given and is positive, it represents the length of the portion of the string which is to be replaced.
* If it is negative, it represents the number of characters from the end of string at which to stop replacing.
* If it is not given, then it will default to api_strlen($string); i.e. end the replacing at the end of string.
* If $length is zero, then this function will have the effect of inserting replacement into the string at the given start offset.
* If given and is positive, it represents the length of the portion of the string which is
* to be replaced. If it is negative, it represents the number of characters from the end of
* string at which to stop replacing. If it is not given, then it will default to
* api_strlen($string); i.e. end the replacing at the end of string. If $length is zero,
* then this function will have the effect of inserting replacement into the string at the
* given start offset.
* @param string $encoding (optional) The used internally by this function character encoding.
* If it is omitted, the platform character set will be used by default.
*
@ -1486,15 +1443,21 @@ function api_ucwords($string, $encoding = null)
/**
* Performs a regular expression match, UTF-8 aware when it is applicable.
*
* @param string $pattern the pattern to search for, as a string
* @param string $subject the input string
* @param array &$matches (optional) If matches is provided,
* then it is filled with the results of search (as an array).
* $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.
* @param int $flags (optional) Could be PREG_OFFSET_CAPTURE. If this flag is passed, for every occurring match the appendant string offset will also be returned.
* Note that this changes the return value in an array where every element is an array consisting of the matched string at index 0 and its string offset into subject at index 1.
* @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The optional parameter offset can be used to specify the alternate place from which to start the search.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param string $pattern the pattern to search for, as a string
* @param string $subject the input string
* @param array &$matches (optional) If matches is provided,
* then it is filled with the results of search (as an array).
* $matches[0] will contain the text that matched the full pattern, $matches[1] will have the
* text that matched the first captured parenthesized subpattern, and so on.
* @param int $flags (optional) Could be PREG_OFFSET_CAPTURE. If this flag is passed, for every occurring match
* the appendant string offset will also be returned. Note that this changes the return value
* in an array where every element is an array consisting of the matched string at index 0 and
* its string offset into subject at index 1.
* @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The
* optional parameter offset can be used to specify the alternate place from which to start
* the search.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted,
* the platform character set will be used by default.
*
* @return int|bool returns the number of times pattern matches or FALSE if an error occurred
*
@ -1518,17 +1481,24 @@ function api_preg_match(
/**
* Performs a global regular expression match, UTF-8 aware when it is applicable.
*
* @param string $pattern the pattern to search for, as a string
* @param string $subject the input string
* @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags
* @param int $flags (optional) Can be a combination of the following flags (note that it doesn't make sense to use PREG_PATTERN_ORDER together with PREG_SET_ORDER):
* PREG_PATTERN_ORDER - orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an array of strings matched by the first parenthesized subpattern, and so on;
* PREG_SET_ORDER - orders results so that $matches[0] is an array of first set of matches, $matches[1] is an array of second set of matches, and so on;
* PREG_OFFSET_CAPTURE - If this flag is passed, for every occurring match the appendant string offset will also be returned. Note that this changes the value of matches
* in an array where every element is an array consisting of the matched string at offset 0 and its string offset into subject at offset 1.
* If no order flag is given, PREG_PATTERN_ORDER is assumed.
* @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The optional parameter offset can be used to specify the alternate place from which to start the search.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param string $pattern the pattern to search for, as a string
* @param string $subject the input string
* @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags
* @param int $flags (optional) Can be a combination of the following flags (note that it doesn't
* make sense to use PREG_PATTERN_ORDER together with PREG_SET_ORDER): PREG_PATTERN_ORDER -
* orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an
* array of strings matched by the first parenthesized subpattern, and so on; PREG_SET_ORDER -
* orders results so that $matches[0] is an array of first set of matches, $matches[1] is an
* array of second set of matches, and so on; PREG_OFFSET_CAPTURE - If this flag is passed,
* for every occurring match the appendant string offset will also be returned. Note that this
* changes the value of matches in an array where every element is an array consisting of the
* matched string at offset 0 and its string offset into subject at offset 1. If no order flag
* is given, PREG_PATTERN_ORDER is assumed.
* @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The
* optional parameter offset can be used to specify the alternate place from which to start
* the search.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted,
* the platform character set will be used by default.
*
* @return int|bool returns the number of full pattern matches (which might be zero), or FALSE if an error occurred
* @param string $pattern the pattern to search for, as a string
* @param string $subject the input string
* @param int $limit (optional) If specified, then only substrings up to $limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or null means "no limit" and, as is standard across PHP.
* @param int $flags (optional) $flags can be any combination of the following flags (combined with bitwise | operator):
* PREG_SPLIT_NO_EMPTY - if this flag is set, only non-empty pieces will be returned;
* PREG_SPLIT_DELIM_CAPTURE - if this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well;
* PREG_SPLIT_OFFSET_CAPTURE - If this flag is set, for every occurring match the appendant string offset will also be returned.
* Note that this changes the return value in an array where every element is an array consisting of the matched string at offset 0 and its string offset into subject at offset 1.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param int $limit (optional) If specified, then only substrings up to $limit are returned with the
* rest of the string being placed in the last substring. A limit of -1, 0 or null means "no
* limit" and, as is standard across PHP.
* @param int $flags (optional) $flags can be any combination of the following flags (combined with
* bitwise | operator): PREG_SPLIT_NO_EMPTY - if this flag is set, only non-empty pieces will
* be returned; PREG_SPLIT_DELIM_CAPTURE - if this flag is set, parenthesized expression in the
* delimiter pattern will be captured and returned as well; PREG_SPLIT_OFFSET_CAPTURE - If this
* flag is set, for every occurring match the appendant string offset will also be returned.
* Note that this changes the return value in an array where every element is an array
* consisting of the matched string at offset 0 and its string offset into subject at offset 1.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return array returns an array containing substrings of $subject split along boundaries matched by $pattern
* @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface language is assumed then.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface
* language is assumed then.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the
* platform character set will be used by default.
*
* @return int Returns <0if$string1islessthan$string2;> 0 if $string1 is greater than $string2; and 0 if the strings are equal.
* This function is aimed at replacing the function strcasecmp() for human-language strings.
* @return int Returns <0if$string1islessthan$string2;> 0 if $string1 is greater than $string2; and 0 if the
* strings are equal. This function is aimed at replacing the function strcasecmp() for human-language