DEF_ENCODING
DEF_ENCODING
Default file encoding.
Used by multibyte string functions.
String standard object.
This is a helper class for working with strings.
subString(integer $startPosition, integer $length) : $this
Returns a substring from the current string.
integer | $startPosition | From which char position will the substring start. |
integer | $length | Where will the substring end. If 0 - to the end of string. |
replace(string|array $search, string|array $replace) : $this
Replaces the occurrences of $search inside the current string with $replace.
This function is CASE-INSENSITIVE.
string|array | $search | String, or array of strings, that will replaced. |
string|array | $replace | String, or array of strings, with whom $search occurrences will be replaced. |
pregReplace(string $pattern, mixed $replacement, integer $limit = -1, null $count = null) : $this
Replace string using regex
string | $pattern | The pattern to search for. It can be either a string or an array with strings. |
mixed | $replacement | The string or an array with strings to replace. |
integer | $limit | The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit). |
null | $count | If specified, this variable will be filled with the number of replacements done. |
explode(string $delimiter, null|integer $limit = null) : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject
Explode the current string with the given delimiter and return ArrayObject with the exploded values.
string | $delimiter | String upon which the current string will be exploded. |
null|integer | $limit | Limit the number of exploded items. |
ArrayObject object containing exploded values.
split(integer $chunkSize = 1) : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject
Split the string into chunks.
integer | $chunkSize | Size of each chunk. Set it to 1 if you want to get all the characters from the string. |
ArrayObject containing string chunks.
hash(string $algo = 'sha1') : $this
Generate a hash value from the current string using the defined algorithm.
string | $algo | Name of the algorithm used for calculation (md5, sha1, ripemd160,...). |
htmlEntityEncode(string|null $flags = null, string $encoding = 'UTF-8') : $this
Convert all HTML entities to their applicable characters.
For more info visit: http://www.php.net/manual/en/function.htmlentities.php
string|null | $flags | Default flags are set to ENT_COMPAT | ENT_HTML401 |
string | $encoding | Which encoding will be used in the conversion. Default is UTF-8. |
chunkSplit(integer $chunkSize = 76, string $endChar = "\n") : $this
Split the string into chunks with each chunk ending with $endChar.
This function is multi-byte safe.
integer | $chunkSize | Size of each chunk. |
string | $endChar | String that will be appended to the end of each chunk. |
parseString() : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject
Parse current string as a query string and return ArrayObject with results.
ArrayObject from the parsed string.
format(string|array $args) : $this
Format the string according to the provided $format.
string|array | $args | Arguments used for string formatting. For more info visit http://www.php.net/manual/en/function.sprintf.php |
padLeft(integer $length, string $padString) : $this
Pad the string to a certain length with another string.
integer | $length | Length to which to pad. |
string | $padString | String that will be appended. |
padRight(integer $length, string $padString) : $this
Pad the string to a certain length with another string.
integer | $length | Length to which to pad. |
string | $padString | String that will be appended. |
padBoth(integer $length, string $padString) : $this
Pad the string to a certain length with another string.
integer | $length | Length to which to pad. |
string | $padString | String that will be appended. |
wordWrap(integer $length, string $break = "\n", boolean $cut = false) : $this
Wraps a string to a given number of characters using a string break character.
integer | $length | The number of characters at which the string will be wrapped. |
string | $break | The line is broken using the optional break parameter. |
boolean | $cut | If the cut is set to TRUE, the string is always wrapped at or before the specified width. So if you have a word that is larger than the given width, it is broken apart. |
truncate(integer $length, string $ellipsis = '') : $this
Truncate the string to the given length without breaking words.
integer | $length | Length to which you which to trim. |
string | $ellipsis | Ellipsis is calculated in the string $length. |
match(string $regEx, boolean $matchAll = true) : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject|boolean
Preg matches current string against the given regular expression.
If you just wish if string is contained within the current string, use StringObject::contains().
string | $regEx | Regular expression to match. |
boolean | $matchAll | Use preg_match_all, or just preg_match. Default is preg_match_all. |
If there are matches, an ArrayObject with the the $matches is returned, else, false is returned.
contains(string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject $needle) : boolean
Checks if a string contains the given $char.
If the $char is present, true is returned. If you wish to match a string to a regular expression use StringObject:match().
string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject | $needle | String you wish to check if it exits within the current string. |
True if current string contains the $needle. Otherwise false is returned.
containsAny(array|\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject $needle) : boolean
Checks if a string contains any of the given $char.
If any of given $char is present, true is returned.
array|\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject | $needle | Array of characters you wish to check |
True if current string contains the $needle. Otherwise false is returned.
equals(string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject $string) : boolean
Check if $string is equal to current string.
Note that this comparison is case sensitive and binary safe.
string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject | $string | String to compare. |
True if current string is equal to $string. Otherwise false is returned.
stringPosition(string $string, integer $offset) : integer|boolean
Returns the position of the given $string inside the current string object.
Boolean false is returned if the $string is not present inside the current string. NOTE: Use type validation check in order no to mistake the position '0' (zero) for (bool) false.
string | $string | |
integer | $offset |
If $string is contained within the current string, the position of $string is returned, otherwise false.
startsWith(string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject $string) : boolean
Checks if the current string starts with the given $string.
string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject | $string | String to check. |
If current string starts with $string, true is returned, otherwise false.
endsWith(string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject $string) : boolean
Checks if the current string ends with the given $string.
string|\app\framework\Component\StdLib\StdObject\StringObject\StringObject | $string | String to check. |
If current string ends with $string, true is returned, otherwise false.
longerThan(integer $num, boolean $inclusive = false) : boolean
Checks if the string length is great than the given length.
integer | $num | Length against which you wish to check. |
boolean | $inclusive | Do you want the check to be inclusive or not. Default is false (not inclusive). |
If current string size is longer than the given $num, true is returned, otherwise false.
isSerialized(string $value, mixed $result = null) : boolean
Checks if a string is serialized using quick string manipulation to throw out obviously incorrect strings. Unserialize is then run on the string to perform the final verification.
Valid serialized forms are the following:
b:1;
i:1;
d:0.2;
s:4:"test";
a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}
O:8:"stdClass":0:{}
N;
string | $value | Value to test for serialized form |
mixed | $result | Result of unserialize() of the $value |
True if $value is serialized data, otherwise false
wordCount(integer $format) : mixed|\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject
Get the number of words in the string.
integer | $format | Specify the return format: 0 - return number of words 1 - return an ArrayObject containing all the words found inside the string 2 - returns an ArrayObject, where the key is the numeric position of the word inside the string and the value is the actual word itself |
An ArrayObject or integer, based on the wanted $format, with the stats about the words in the string.
subStringCount(string $string, null|integer $offset, null|integer $length = null) : integer
Get number of string occurrences in current string.
string | $string | String to search for |
null|integer | $offset | The offset where to start counting |
null|integer | $length | The maximum length after the specified offset to search for the substring. It outputs a warning if the offset plus the length is greater than the haystack length. |