public static
boolean
|
#
is_ascii( string $str )
Tests whether a string contains only 7bit ASCII bytes. This is used to
determine when to use native functions or UTF-8 functions.
Tests whether a string contains only 7bit ASCII bytes. This is used to
determine when to use native functions or UTF-8 functions.
Parameters
- $str
string string to check
Returns
boolean
|
public static
string
|
#
strip_ascii_ctrl( string $str )
Strips out device control codes in the ASCII range.
Strips out device control codes in the ASCII range.
Parameters
- $str
string string to clean
Returns
string
|
public static
string
|
#
strip_non_ascii( string $str )
Strips out all non-7bit ASCII bytes.
Strips out all non-7bit ASCII bytes.
Parameters
- $str
string string to clean
Returns
string
|
public static
integer
|
#
strlen( string $str )
Returns the length of the given string.
Returns the length of the given string.
Parameters
- $str
string string being measured for length
Returns
integer
See
|
public static
integer
|
#
strpos( string $str, string $search, integer $offset = 0 )
Finds position of first occurrence of a UTF-8 string.
Finds position of first occurrence of a UTF-8 string.
Parameters
- $str
string haystack
- $search
string needle
- $offset
integer offset from which character in haystack to start searching
Returns
integer position of needle
boolean FALSE if the needle is not found
Author
See
|
public static
integer
|
#
strrpos( string $str, string $search, integer $offset = 0 )
Finds position of last occurrence of a char in a UTF-8 string.
Finds position of last occurrence of a char in a UTF-8 string.
Parameters
- $str
string haystack
- $search
string needle
- $offset
integer offset from which character in haystack to start searching
Returns
integer position of needle
boolean FALSE if the needle is not found
Author
See
|
public static
string
|
#
substr( string $str, integer $offset, integer $length = NULL )
Returns part of a UTF-8 string.
Returns part of a UTF-8 string.
Parameters
- $str
string input string
- $offset
integer offset
- $length
integer length limit
Returns
string
Author
See
|
public static
string
|
#
substr_replace( string $str, string $replacement, integer $offset, $length = NULL )
Replaces text within a portion of a UTF-8 string.
Replaces text within a portion of a UTF-8 string.
Parameters
- $str
string input string
- $replacement
string replacement string
- $offset
integer offset
- $length
Returns
string
Author
See
|
public static
string
|
#
strtolower( string $str )
Makes a UTF-8 string lowercase.
Makes a UTF-8 string lowercase.
Parameters
- $str
string mixed case string
Returns
string
Author
See
|
public static
string
|
#
strtoupper( string $str )
Makes a UTF-8 string uppercase.
Makes a UTF-8 string uppercase.
Parameters
- $str
string mixed case string
Returns
string
Author
See
|
public static
string
|
#
ucfirst( string $str )
Makes a UTF-8 string's first character uppercase.
Makes a UTF-8 string's first character uppercase.
Parameters
- $str
string mixed case string
Returns
string
Author
See
|
public static
string
|
#
ucwords( string $str )
Makes the first character of every word in a UTF-8 string uppercase.
Makes the first character of every word in a UTF-8 string uppercase.
Parameters
- $str
string mixed case string
Returns
string
Author
See
|
public static
integer
|
#
strcasecmp( string $str1, string $str2 )
Case-insensitive UTF-8 string comparison.
Case-insensitive UTF-8 string comparison.
Parameters
- $str1
string string to compare
- $str2
string string to compare
Returns
integer less than 0 if str1 is less than str2
integer greater than 0 if str1 is greater than str2
integer 0 if they are equal
Author
See
|
public static
string
|
#
str_ireplace( string|array $search, string|array $replace, string|array $str, integer & $count = NULL )
Returns a string or an array with all occurrences of search in subject
(ignoring case). replaced with the given replace value.
Returns a string or an array with all occurrences of search in subject
(ignoring case). replaced with the given replace value.
Parameters
- $search
string|array text to replace
- $replace
string|array replacement text
- $str
string|array subject text
- $count
integer number of matched and replaced needles will be returned via this parameter which
is passed by reference
Returns
string if the input was a string
array if the input was an array
Author
See
Note
It's not fast and gets slower if $search and/or $replace are arrays.
|
public static
string
|
#
stristr( string $str, string $search )
Case-insenstive UTF-8 version of strstr. Returns all of input string from the
first occurrence of needle to the end.
Case-insenstive UTF-8 version of strstr. Returns all of input string from the
first occurrence of needle to the end.
Parameters
- $str
string input string
- $search
string needle
Returns
string matched substring if found
boolean FALSE if the substring was not found
Author
See
|
public static
integer
|
#
strspn( string $str, string $mask, integer $offset = NULL, integer $length = NULL )
Finds the length of the initial segment matching mask.
Finds the length of the initial segment matching mask.
Parameters
- $str
string input string
- $mask
string mask for search
- $offset
integer start position of the string to examine
- $length
integer length of the string to examine
Returns
integer length of the initial segment that contains characters in the mask
Author
See
|
public static
integer
|
#
strcspn( string $str, string $mask, integer $offset = NULL, integer $length = NULL )
Finds the length of the initial segment not matching mask.
Finds the length of the initial segment not matching mask.
Parameters
- $str
string input string
- $mask
string mask for search
- $offset
integer start position of the string to examine
- $length
integer length of the string to examine
Returns
integer length of the initial segment that contains characters not in the mask
Author
See
|
public static
string
|
#
str_pad( string $str, integer $final_str_length, string $pad_str = ' ', string $pad_type = STR_PAD_RIGHT )
Pads a UTF-8 string to a certain length with another string.
Pads a UTF-8 string to a certain length with another string.
Parameters
- $str
string input string
- $final_str_length
integer desired string length after padding
- $pad_str
string string to use as padding
- $pad_type
string padding type: STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH
Returns
string
Author
See
|
public static
array
|
#
str_split( string $str, integer $split_length = 1 )
Converts a UTF-8 string to an array.
Converts a UTF-8 string to an array.
Parameters
- $str
string input string
- $split_length
integer maximum length of each chunk
Returns
array
Author
See
|
public static
string
|
#
strrev( string $str )
Reverses a UTF-8 string.
Parameters
- $str
string string to be reversed
Returns
string
Author
See
|
public static
string
|
#
trim( string $str, string $charlist = NULL )
Strips whitespace (or other UTF-8 characters) from the beginning and end of a
string.
Strips whitespace (or other UTF-8 characters) from the beginning and end of a
string.
Parameters
- $str
string input string
- $charlist
string string of characters to remove
Returns
string
Author
See
|
public static
string
|
#
ltrim( string $str, string $charlist = NULL )
Strips whitespace (or other UTF-8 characters) from the beginning of a
string.
Strips whitespace (or other UTF-8 characters) from the beginning of a
string.
Parameters
- $str
string input string
- $charlist
string string of characters to remove
Returns
string
Author
See
|
public static
string
|
#
rtrim( string $str, string $charlist = NULL )
Strips whitespace (or other UTF-8 characters) from the end of a string.
Strips whitespace (or other UTF-8 characters) from the end of a string.
Parameters
- $str
string input string
- $charlist
string string of characters to remove
Returns
string
Author
See
|
public static
integer
|
#
ord( string $chr )
Returns the unicode ordinal for a character.
Returns the unicode ordinal for a character.
Parameters
- $chr
string UTF-8 encoded character
Returns
integer
Author
See
|
public static
array
|
#
to_unicode( string $str )
Takes an UTF-8 string and returns an array of ints representing the Unicode
characters. Astral planes are supported i.e. the ints in the output can be >
0xFFFF. Occurrances of the BOM are ignored. Surrogates are not allowed.
Takes an UTF-8 string and returns an array of ints representing the Unicode
characters. Astral planes are supported i.e. the ints in the output can be >
0xFFFF. Occurrances of the BOM are ignored. Surrogates are not allowed.
The Original Code is Mozilla Communicator client code. The Initial Developer
of the Original Code is Netscape Communications Corporation. Portions created by
the Initial Developer are Copyright (C) 1998 the Initial Developer. Ported to
PHP by Henri Sivonen <hsivonen@iki .fi>, see http://hsivonen.iki.fi/php-utf8/.
Slight modifications to fit with phputf8 library by Harry Fuecks <hfuecks@gmail.com>.
Parameters
- $str
string UTF-8 encoded string
Returns
array unicode code points
boolean FALSE if the string is invalid
|
public static
string
|
#
from_unicode( array $arr )
Takes an array of ints representing the Unicode characters and returns a
UTF-8 string. Astral planes are supported i.e. the ints in the input can be >
0xFFFF. Occurrances of the BOM are ignored. Surrogates are not allowed.
Takes an array of ints representing the Unicode characters and returns a
UTF-8 string. Astral planes are supported i.e. the ints in the input can be >
0xFFFF. Occurrances of the BOM are ignored. Surrogates are not allowed.
The Original Code is Mozilla Communicator client code. The Initial Developer
of the Original Code is Netscape Communications Corporation. Portions created by
the Initial Developer are Copyright (C) 1998 the Initial Developer. Ported to
PHP by Henri Sivonen <hsivonen@iki .fi>, see http://hsivonen.iki.fi/php-utf8/.
Slight modifications to fit with phputf8 library by Harry Fuecks <hfuecks@gmail.com>.
Parameters
- $arr
array unicode code points representing a string
Returns
string utf8 string of characters
boolean FALSE if a code point cannot be found
|
public static
|
|
public static
|
|
public static
|
|