Joomla! 1.5 API

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2011 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.

 Class JString

Description

String handling class for utf-8 data Wraps the phputf8 library All functions assume the validity of utf-8 strings.

  • since: 1.5

Located in /joomla/utilities/string.php (line 52)

Class JString   (Subpackage Utilities)
Method Summary
Static method static string ltrim (string $str, [string $charlist = FALSE])
Static method static string rtrim (string $str, [string $charlist = FALSE])
Static method static int strcasecmp (string $str1, string $str2)
Static method static int strcspn (string $str, string $mask, [int $start = NULL], [int $length = NULL])
Static method static string stristr (string $str, string $search)
Static method static mixed strpos ($str $str, $search $search, [$offset $offset = FALSE])
Static method static string strrev (string $str)
Static method static mixed strrpos ($str $str, $search $search)
Static method static void strspn (string $str, string $mask, [int $start = NULL], [int $length = NULL])
Static method static void str_ireplace (string $search, string $replace, string $str, [int $count = NULL])
Static method static array str_split (string $str, [int $split_len = 1])
Static method static mixed substr (string $str, integer $offset, [integer $length = FALSE])
Static method static void substr_replace (string $str, string $repl, int $start, [int $length = NULL])
Static method static string transcode (string $source, string $from_encoding, string $to_encoding)
Static method static string trim (string $str, [string $charlist = FALSE])
Static method static string ucfirst (string $str)
Static method static string ucwords (string $str)
Method int strlen (string $str)
Method mixed strtolower (string $str)
Method mixed strtoupper (string $str)
Methods
ltrim (line 334)

UTF-8 aware replacement for ltrim()

Strip whitespace (or other characters) from the beginning of a string Note: you only need to use this if you are supplying the charlist optional arg and it contains UTF-8 characters. Otherwise ltrim will work normally on a UTF-8 string

string ltrim (string $str, [string $charlist = FALSE])
  • string $str: the string to be trimmed
  • string $charlist: the optional charlist of additional characters to trim
rtrim (line 358)

UTF-8 aware replacement for rtrim()

Strip whitespace (or other characters) from the end of a string Note: you only need to use this if you are supplying the charlist optional arg and it contains UTF-8 characters. Otherwise rtrim will work normally on a UTF-8 string

string rtrim (string $str, [string $charlist = FALSE])
  • string $str: the string to be trimmed
  • string $charlist: the optional charlist of additional characters to trim
strcasecmp (line 208)

UTF-8 aware alternative to strcasecmp A case insensivite string comparison

  • return: < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
  • see: http://www.php.net/strcasecmp
  • access: public
int strcasecmp (string $str1, string $str2)
  • string $str1: string 1 to compare
  • string $str2: string 2 to compare
strcspn (line 227)

UTF-8 aware alternative to strcspn Find length of initial segment not matching mask

  • return: the length of the initial segment of str1 which does not contain any of the characters in str2
  • see: http://www.php.net/strcspn
  • access: public
int strcspn (string $str, string $mask, [int $start = NULL], [int $length = NULL])
  • string $str
  • string $mask: the mask
  • int $start: Optional starting character position (in characters)
  • int $length: Optional length
stristr (line 252)

UTF-8 aware alternative to stristr Returns all of haystack from the first occurrence of needle to the end.

needle and haystack are examined in a case-insensitive manner Find first occurrence of a string using case insensitive comparison

string stristr (string $str, string $search)
  • string $str: the haystack
  • string $search: the needle
strlen (line 154)

UTF-8 aware alternative to strlen Returns the number of characters in the string (NOT THE NUMBER OF BYTES),

int strlen (string $str)
  • string $str: UTF-8 string
strpos (line 66)

UTF-8 aware alternative to strpos Find position of first occurrence of a string

mixed strpos ($str $str, $search $search, [$offset $offset = FALSE])
  • $str $str: - string String being examined
  • $search $search: - string String being searced for
  • $offset $offset: - int Optional, specifies the position from which the search should be performed
strrev (line 268)

UTF-8 aware alternative to strrev Reverse a string

string strrev (string $str)
  • string $str: String to be reversed
strrpos (line 86)

UTF-8 aware alternative to strrpos Finds position of last occurrence of a string

mixed strrpos ($str $str, $search $search)
  • $str $str: - string String being examined
  • $search $search: - string String being searced for
strspn (line 286)

UTF-8 aware alternative to strspn Find length of initial segment matching mask

void strspn (string $str, string $mask, [int $start = NULL], [int $length = NULL])
  • string $str: the haystack
  • string $mask: the mask
  • int $start: start optional
  • int $length: length optional
strtolower (line 124)

UTF-8 aware alternative to strtlower

Make a string lowercase Note: The concept of a characters "case" only exists is some alphabets such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does not exist in the Chinese alphabet, for example. See Unicode Standard Annex #21: Case Mappings

mixed strtolower (string $str)
  • string $str
strtoupper (line 141)

UTF-8 aware alternative to strtoupper

Make a string uppercase Note: The concept of a characters "case" only exists is some alphabets such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does not exist in the Chinese alphabet, for example. See Unicode Standard Annex #21: Case Mappings

mixed strtoupper (string $str)
  • string $str
str_ireplace (line 170)

UTF-8 aware alternative to str_ireplace Case-insensitive version of str_replace

void str_ireplace (string $search, string $replace, string $str, [int $count = NULL])
  • string $search: string to search
  • string $replace: existing string to replace
  • string $str: new string to replace with
  • int $count: optional count value to be passed by referene
str_split (line 191)

UTF-8 aware alternative to str_split Convert a string to an array

array str_split (string $str, [int $split_len = 1])
  • string $str: UTF-8 encoded
  • int $split_len: number to characters to split string by
substr (line 102)

UTF-8 aware alternative to substr Return part of a string given character offset (and optionally length)

mixed substr (string $str, integer $offset, [integer $length = FALSE])
  • string $str
  • integer $offset: number of UTF-8 characters offset (from left)
  • integer $length: (optional) length in UTF-8 characters from offset
substr_replace (line 310)

UTF-8 aware substr_replace Replace text within a portion of a string

void substr_replace (string $str, string $repl, int $start, [int $length = NULL])
  • string $str: the haystack
  • string $repl: the replacement string
  • int $start: start
  • int $length: length (optional)
transcode (line 434)

Transcode a string.

  • return: Transcoded string
  • since: 1.5
string transcode (string $source, string $from_encoding, string $to_encoding)
  • string $source: The string to transcode.
  • string $from_encoding: The source encoding.
  • string $to_encoding: The target encoding.
trim (line 382)

UTF-8 aware replacement for trim()

Strip whitespace (or other characters) from the beginning and end of a string Note: you only need to use this if you are supplying the charlist optional arg and it contains UTF-8 characters. Otherwise trim will work normally on a UTF-8 string

string trim (string $str, [string $charlist = FALSE])
  • string $str: the string to be trimmed
  • string $charlist: the optional charlist of additional characters to trim
ucfirst (line 402)

UTF-8 aware alternative to ucfirst Make a string's first character uppercase

string ucfirst (string $str)
  • string $str
ucwords (line 418)

UTF-8 aware alternative to ucwords Uppercase the first character of each word in a string

string ucwords (string $str)
  • string $str
Support Joomla!