StringUtil.php
29 public static function getDump($variable, $strlen=100, $width=25, $depth=10, $i=0, &$objects = []) {
130 * Based on https://stackoverflow.com/questions/16583676/shorten-text-without-splitting-words-or-breaking-html-tags#answer-16584383
145 $dom->loadHTML(mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
150 $walk = function(\DomNode $node) use (&$reachedLimit, &$totalLen, &$toRemove, &$walk, $length, $suffix, $exact) {
161 $node->nodeValue = $exact ? substr($node->nodeValue, 0, $nodeLen-($totalLen-$length)) : substr($node->nodeValue, 0, $spacePos);
190 * code based on: http://stackoverflow.com/questions/1292121/how-to-generate-the-snippet-like-generated-by-google-with-php-and-mysql
231 * @note This method searches for occurences of <a..href="xxx"..>, <img..src="xxx"..>, <video..src="xxx"..>,
232 * <audio..src="xxx"..>, <input..src="xxx"..>, <form..action="xxx"..>, <link..href="xxx"..>, <script..src="xxx"..>
257 return array_merge($links[1], $images[1], $videos[1], $audios[1], $buttons[1], $actions[1], $css[1], $scripts[1]);
362 * @param $firstLowerCase Boolean whether the first character should be lowercase or not (default: _false_)
385 $patterns = ['/\//', '/\^/', '/\./', '/\$/', '/\|/', '/\(/', '/\)/', '/\[/', '/\]/', '/\*/', '/\+/', '/\?/', '/\{/', '/\}/'];
386 $replace = ['\/', '\^', '\.', '\$', '\|', '\(', '\)', '\[', '\]', '\*', '\+', '\?', '\{', '\}'];
415 * Code from http://stackoverflow.com/questions/2103797/url-friendly-username-in-php/2103815#2103815
424 html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1',
static removeTrailingComma($string)
Remove a trailing comma, if existing.
Definition: StringUtil.php:396
static getDump($variable, $strlen=100, $width=25, $depth=10, $i=0, &$objects=[])
Get the dump of a variable as string.
Definition: StringUtil.php:29
static splitQuoted($string, $delim='//', $quoteChr='"', $preserve=false)
Split string preserving quoted strings code based on: http://www.php.net/manual/en/function....
Definition: StringUtil.php:341
static underScoreToCamelCase($string, $firstLowerCase=false)
Convert a string in underscore notation to camel case notation.
Definition: StringUtil.php:365
StringUtil provides support for string manipulation.
Definition: StringUtil.php:18
static excerpt($string, $phrase, $radius=100)
Create an excerpt from the given text around the given phrase code based on: http://stackoverflow....
Definition: StringUtil.php:195
static slug($string)
Converts all accent characters to ASCII characters.
Definition: StringUtil.php:419
static escapeForRegex($string)
Escape characters of a string for use in a regular expression Code from http://php....
Definition: StringUtil.php:384
static guidv4()
Generate a v4 UUID Code from https://stackoverflow.com/questions/2040240/php-function-to-generate-v4-...
Definition: StringUtil.php:433
static quotesplit($string)
Split a quoted string code from: http://php3.de/manual/de/function.split.php.
Definition: StringUtil.php:275
static cropString($text, $length=100, $suffix='…', $exact=false)
Truncate a string up to a number of characters while preserving whole words and HTML tags.
Definition: StringUtil.php:137