Detailed Description
StringUtil provides support for string manipulation.
Definition at line 18 of file StringUtil.php.
Static Public Member Functions | |
static | getDump ($var) |
static | cropString ($text, $length=100, $suffix='…', $isHTML=true) |
static | excerpt ($string, $phrase, $radius=100) |
static | getUrls ($string) |
static | quotesplit ($string) |
static | splitQuoted ($string, $delim='//', $quoteChr='"', $preserve=false) |
static | underScoreToCamelCase ($string, $firstLowerCase=false) |
static | escapeForRegex ($string) |
static | removeTrailingComma ($string) |
static | getBoolean ($string) |
static | slug ($string) |
Member Function Documentation
|
static |
Get the dump of a variable as string.
- Parameters
-
$var The variable to dump.
- Returns
- String
Definition at line 25 of file StringUtil.php.
|
static |
Truncate a string up to a number of characters while preserving whole words and HTML tags code based on: http://www.dzone.com/snippets/truncate-text-preserving-html.
- Parameters
-
$text String to truncate. $length Length of returned string, excluding suffix. $suffix Ending to be appended to the trimmed string. $isHTML If true, HTML tags would be handled correctly
- Returns
- String
Definition at line 42 of file StringUtil.php.
|
static |
Create an excerpt from the given text around the given phrase code based on: http://stackoverflow.com/questions/1292121/how-to-generate-the-snippet-like-generated-by-google-with-php-and-mysql.
- Parameters
-
$string $phrase $radius
Definition at line 95 of file StringUtil.php.
|
static |
Extraxt urls from a string.
- Parameters
-
$string The string to search in
- Returns
- An array with urls
- Note
- This method searches for occurences of <a..href="xxx"..>, <img..src="xxx"..>, <input..src="xxx"..>, <form..action="xxx"..>, <link..href="xxx"..>, <script..src="xxx"..> and extracts xxx.
Definition at line 135 of file StringUtil.php.
|
static |
Split a quoted string code from: http://php3.de/manual/de/function.split.php.
- Parameters
-
$string The string to split
- Returns
- An array of strings
Definition at line 173 of file StringUtil.php.
|
static |
Split string preserving quoted strings code based on: http://www.php.net/manual/en/function.explode.php#94024.
- Parameters
-
$string String to split $delim Regexp to use in preg_split $quoteChr Quote character $preserve Boolean whether to preserve the quote character or not
- Returns
- Array
Definition at line 239 of file StringUtil.php.
|
static |
Convert a string in underscore notation to camel case notation.
Code from http://snipt.net/hongster/underscore-to-camelcase/
- Parameters
-
$string The string to convert $firstLowerCase Boolean whether the first character should be lowercase or not (default: false)
- Returns
- The converted string
Definition at line 263 of file StringUtil.php.
|
static |
Escape characters of a string for use in a regular expression Code from http://php.net/manual/de/function.preg-replace.php.
- Parameters
-
$string The string
- Returns
- The escaped string
Definition at line 282 of file StringUtil.php.
|
static |
Remove a trailing comma, if existing.
- Parameters
-
$string The string to crop
- Returns
- The string
Definition at line 294 of file StringUtil.php.
|
static |
Get the boolean value of a string.
- Parameters
-
$string
- Returns
- Boolean or the string, if it does not represent a boolean.
Definition at line 303 of file StringUtil.php.
|
static |
Converts all accent characters to ASCII characters.
Code from http://stackoverflow.com/questions/2103797/url-friendly-username-in-php/2103815#2103815
- Parameters
-
$string Text that might have accent characters
- Returns
- string Filtered string with replaced "nice" characters.
Definition at line 317 of file StringUtil.php.