Properties

$str

$str : string

Type

string — Internal php string representation of the String\String object.

Methods

__construct()

__construct(string $string)

Constructor

Parameters

string $string

The initial value for the String\String object.

offsetExists()

offsetExists(int $index) : bool

Checks for the existance of the given index in the string.

Parameters

int $index

The desired index.

Returns

bool

offsetGet()

offsetGet(int $index) : string|bool

Returns the character at the given index.

Parameters

int $index

The desired index.

Returns

string|bool —

The character at the given index or false if the index doesn't exist.

offsetSet()

offsetSet(int $index, string $value)

Replaces the character at the given index.

Parameters

int $index

The desired index.

string $value

Replacement character.

Throws

\Exception

offsetUnset()

offsetUnset(int $index)

Erases the character at the given index.

Parameters

int $index

The desired index.

append()

append(string $string)

Appends a string to the current value.

Parameters

string $string

The string to append.

trim()

trim(string $charList, bool $alter) : string

This function returns a string with whitespace stripped from the beginning and end of the string.

Parameters

string $charList

A list with all characters that you want to be stripped

bool $alter

If true the current string value will be altered, otherwhise it will just be returned but it won't change.

Returns

string —

If $alter is false.

leftTrim()

leftTrim(string $charList, bool $alter) : string

This function returns a string with whitespace stripped from the beginning of the string.

Parameters

string $charList

A list with all characters that you want to be stripped

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

rightTrim()

rightTrim(string $charList, bool $alter) : string

This function returns a string with whitespace stripped from the end of the string.

Parameters

string $charList

A list with all characters that you want to be stripped

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

chunkSplit()

chunkSplit(int $chunkLen, string $end, bool $alter) : string

Split a string into smaller chunks.

Parameters

int $chunkLen

The chunk length.

string $end

The line ending sequence.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

countChars()

countChars(int $mode) : mixed

Return information about characters used in a string.

Parameters

int $mode

See php documentation for count_chars.

Returns

mixed —

Depends on mode. See php documentation for count_chars.

crc32()

crc32(bool $alter) : string

Calculates the crc32 polynomial of a string

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

crypt()

crypt(string $salt, bool $alter) : string

It will return a hashed string using the standard Unix DES-based algorithm or alternative algorithms that may be available on the system.

Parameters

string $salt

An optional salt string to base the hashing on. If not provided, the behaviour is defined by the algorithm implementation and can lead to unexpected results.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

split()

split(string $delimiter, int $limit) : array

Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter.

Parameters

string $delimiter

The boundary string.

int $limit

If limit is set and positive, the returned array will contain a maximum of limit elements with the last element containing the rest of string. If the limit parameter is negative, all components except the last -limit are returned. If the limit parameter is zero, then this is treated as 1.See php documentation for explode.

Returns

array —

Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter. See php documentation for explode.

char()

char(int $char) : string

Returns a one-character string containing the character specified by ascii.

Parameters

int $char

The ASCII code.

Returns

string —

The character for the given ASCII code.

ascii()

ascii(string $char) : int

Returns the ASCII value of the first character of the string.

Parameters

string $char

The character.

Returns

int —

The ASCII for the given character.

parseStr()

parseStr(string $str, array $array)

Parses string as if it were the query string passed via a URL and sets variables in the current scope.

Parameters

string $str

The input string.

array $array

If the second parameter is present, variables are stored in this variable as array elements instead.

binToHex()

binToHex(bool $alter) : string|bool

Returns an ASCII string containing the hexadecimal representation of the string. The conversion is done byte-wise with the high-nibble first.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string|bool —

If $alter is false or FALSE on failure.

hexToBin()

hexToBin(bool $alter) : string|bool

Decodes a hexadecimally encoded binary string.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string|bool —

If $alter is false or FALSE on failure.

htmlEntities()

htmlEntities(int $flags, string $encoding, bool $doubleEncode, bool $alter) : string

Convert all applicable characters to HTML entities.

Parameters

int $flags

A bitmask of one or more of the following flags, which specify how to handle quotes, invalid code unit sequences and the used document type. The default is ENT_COMPAT | ENT_HTML401.

string $encoding

Defines encoding used in conversion. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.

bool $doubleEncode

When is turned off PHP will not encode existing html entities. The default is to convert everything.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

htmlSpecialChars()

htmlSpecialChars(int $flags, string $encoding, bool $doubleEncode, bool $alter) : string

Convert special characters to HTML entities.

Parameters

int $flags

A bitmask of one or more of the following flags, which specify how to handle quotes, invalid code unit sequences and the used document type. The default is ENT_COMPAT | ENT_HTML401.

string $encoding

Defines encoding used in conversion. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.

bool $doubleEncode

When is turned off PHP will not encode existing html entities. The default is to convert everything.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

htmlSpecialCharsDecode()

htmlSpecialCharsDecode(int $flags, bool $alter) : string

Convert special HTML entities back to characters.

Parameters

int $flags

A bitmask of one or more of the following flags, which specify how to handle quotes, invalid code unit sequences and the used document type. The default is ENT_COMPAT | ENT_HTML401.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

htmlEntitiesDecode()

htmlEntitiesDecode()

Convert all HTML entities to their applicable characters.

join()

join(string $glue, array $pieces, bool $alter, bool $return) : string

Join array elements with a string.

Parameters

string $glue

Separator string. Defaults to an empty string.

array $pieces

The array of strings to join.

bool $alter

If true the current string value will be replaced.

bool $return

If true the result will be returned.

Returns

string —

If $return is set to true.

lowerFirst()

lowerFirst(bool $alter) : string

Make a string's first character lowercase.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

md5()

md5(bool $rawOutput, bool $alter) : string

Calculate the md5 hash of a string.

Parameters

bool $rawOutput

If it's set to true the md5 digest is instead returned in raw binary format with a length of 16.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

sha1()

sha1(bool $rawOutput, bool $alter) : string

Calculate the sha1 hash of a string.

Parameters

bool $rawOutput

If it's 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.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

nlToBr()

nlToBr(bool $isXhtml, bool $alter) : string

Inserts HTML line breaks before all newlines in a string.

Parameters

bool $isXhtml

Whether to use XHTML compatible line breaks or not.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

printf()

printf()

Output a formatted string.

similarText()

similarText(string|String $string, float $percent) : int

Calculate the similarity between two strings-

Parameters

string|String $string

The string to compare the current string value to.

float $percent

By passing a reference as second argument, the method will calculate the similarity in percent for you.

Returns

int —

The number of matching chars in both strings.

format()

format() : string

Formats the current string value.

Returns

string —

The formatted string.

replace()

replace(mixed $search, mixed $replace, int $count, bool $alter) : string

Replace all occurrences of the search string with the replacement string.

Parameters

mixed $search

The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.

mixed $replace

The replacement value that replaces found search values. An array may be used to designate multiple replacements.

int $count

If passed, this will be set to the number of replacements performed.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

shuffle()

shuffle(bool $alter) : string

Randomly shuffles a string.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

toArray()

toArray(int $itemLength) : array

Convert a string to an array

Parameters

int $itemLength

Length of the array items.

Returns

array —

The string converted to an array.

wordCount()

wordCount(int $format, string $charList) : int|array

Return information about words used in a string.

Parameters

int $format

Specify the return value of this function. See php documentation for more information.

string $charList

A list of additional characters which will be considered as 'word'.

Returns

int|array —

Returns an array or an integer, depending on the format chosen.

compare()

compare(string|String $str, bool $caseInsensitive, int $length) : int

Performs a comparison between a string and the current string value of the String object.

Parameters

string|String $str

The string to compare to.

bool $caseInsensitive

Whether to perform a case insensitive comparison or not.

int $length

If set to higher than 0 will perform a comparison of the first $length characters.

Returns

int —

Returns 0 it both strings are equal, 1 if the current string value is greater than the other and -1 otherwhise.

stripTags()

stripTags(string $allowableTags, bool $alter) : string

Strip HTML and PHP tags from a string.

Parameters

string $allowableTags

You can use this optional parameter to specify tags which should not be stripped.

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

stripCSlashes()

stripCSlashes(bool $alter) : string

Un-quote string quoted with addcslashes.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

stripSlashes()

stripSlashes(bool $alter) : string

Un-quote a quoted string.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

indexOf()

indexOf(string|String $needle, int $offset, bool $caseInsensitive) : int

Returns the first position of a string found in the current string value.

Parameters

string|String $needle

The string to look for in the current string value.

int $offset

If specified, search will start this number of characters counted from the beginning of the string. If the offset is negative it will be omitted.

bool $caseInsensitive

Whether to perform a case insensitive search or not.

Returns

int —

The position of where the needle exists relative to the beginnning of the current string value.

lastIndexOf()

lastIndexOf(string|String $needle, int $offset, bool $caseInsensitive) : int

Returns the last position of a string found in the current string value.

Parameters

string|String $needle

The string to look for in the current string value.

int $offset

If specified, search will start this number of characters counted from the beginning of the string. If the offset is negative it will be omitted.

bool $caseInsensitive

Whether to perform a case insensitive search or not.

Returns

int —

The position of where the last occurrence of needle was found relative to the beginnning of the current string value.

length()

length() : int

Returns the length of the current string value.

Returns

int —

The length of the string.

toLower()

toLower(bool $alter) : string

Make the string lowercase.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

toUpper()

toUpper(bool $alter) : string

Make the string uppercase.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

upperFirst()

upperFirst(bool $alter) : string

Make a string's first character uppercase.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

upperCaseWords()

upperCaseWords(bool $alter) : string

Uppercase the first character of each word in the string.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

reverse()

reverse(bool $alter) : string

Reverses the string.

Parameters

bool $alter

If true the current string value will be altered, otherwhise it will be returned but it won't change.

Returns

string —

If $alter is false.

tokenize()

tokenize(string $token) : string

Tokenizes the string.

Parameters

string $token

The delimiter used when splitting up the string.

Returns

string —

A string token.

substring()

substring(int $from, int $to, int $length) : string

Returns part of the string.

Parameters

int $from

Start position of the part that will be returned.

int $to

If specified, the end position of the part that will be returned.

int $length

If specified and $to is not specified, the length of characters to return from the start position set by $from.

Returns

string —

The desired part of the string.

contains()

contains(string $needle, bool $caseInsensitive) : bool

Checks if a string is contained in the current string value.

Parameters

string $needle

The string to look for in the current string value.

bool $caseInsensitive

Whether to perform a case insensitive search or not.

Returns

bool —

The existance of the needle in the current string.

equals()

equals(string|String $str) : bool

Checks if two strings are equal.

Parameters

string|String $str

The string to compare to.

Returns

bool —

The equalness of the two strings.

cloneString()

cloneString() : String

Clones the current string value.

Returns

String —

The cloned string.

toString()

toString() : string

Returns the primitive string value of the String object.

Returns

string —

The primitive string value.

__toString()

__toString() : string

Returns the primitive string value of the String object.

Returns

string —

The primitive string value.