Core_Str
in package
String helper
Tags
Table of Contents
Properties
- $_aDisabledAttributes : array<string|int, mixed>
- Array for _stripTagsCallback()
- $_decimalSeparator : null|string
- Decimal separator.
- $_detectedLng : null|string
- Last detected language code by self::translate()
- $_xmlIllegalCharacters : array<string|int, mixed>
- List of illegal characters
Methods
- br2nl() : string
- Convert HTML line breaks to newlines in a string
- convertDimension() : float
- Convert dimension
- convertHtmlToText() : string
- Convert html to text
- convertSizeToBytes() : int
- Convert size from 10M to bytes
- convertSpaces() : string
- Converts different kinds of spaces (U+2002 - U+200D) to regular space
- convertTextToHtml() : string
- Convert text to html
- convertWeight() : float
- Convert weight
- createColor() : string
- Get Color By Entity ID
- cut() : string
- Cut string to defined lenght
- cutSentences() : string
- Укорачивает описание до заданного количества символов, оставляя целое число предложений
- cutWords() : string
- Cut length of words in a string
- declension() : string
- Получение существительного в форме, соответствующей числу
- declensionNumber() : string
- Возвращает строку согласно падежам
- deleteIllegalCharacters() : string
- Delete illegal characters
- endsWith() : bool
- String end with the specified string
- escapeJavascriptVariable() : string
- Escaping apostrophe ('), slashes (\), 'script' and line breaks.
- generateChars() : string
- Get string of rand chars
- getDecimalSeparator() : string
- Get Decimal Separator By Locale
- getHashes() : array<string|int, mixed>
- Метод очищает HTML от ненужных тегов, хеширует и возвращает массив хэшей слов
- getInitials() : mixed
- getLastDetectedLanguageCode() : null|string
- Get last detected language code by self::translate()
- getTextCount() : string
- Convert count from int to K thousands, M million and B billion suffix, e.g. 102010 => 102K
- getTextSize() : string
- Convert size from bytes to kb, mb, etc
- getXmlIllegalCharacters() : array<string|int, mixed>
- Get XML illegal characters
- hex2darker() : mixed
- Darker HEX color
- hex2hsl() : string
- Convert HEX color to RGB or HSL
- hex2ip() : string
- Convert hexadecimal value into IP
- hex2lighter() : mixed
- Lighter HEX color
- hex2rgba() : string
- Convert HEX color to RGB or RGBA
- hideZeros() : string
- Hide last zeros, e.g. '.00', (locale dependent)
- iconv() : mixed
- Convert string to requested character encoding
- idnToAscii() : string
- Encode to IDN ASCII https://www.ietf.org/rfc/rfc3492.txt
- idnToUtf8() : string
- Decode Punycode IDN https://www.ietf.org/rfc/rfc3492.txt
- ip2hex() : mixed
- Convert IP into hexadecimal value
- lcfirst() : string
- lcfirst for utf-8 string
- ltrimUri() : string
- Cut first slash
- removeBOM() : string
- Remove BOM
- removeEmoji() : string
- Remove emoji (UTF8 4 Byte characters)
- rgb2hex() : string
- Convert RGB to HEX color
- rtrimUri() : string
- Cut last slash
- sanitizePhoneNumber() : string
- Sanitize phone numbers
- startsWith() : bool
- String starts with the specified string
- str2ncr() : string
- Convert HTML entity to numeric character reference (NCR)
- stringToSecret() : string
- Mask parts of a string with the asterisk character
- stripTags() : string
- Удаление HTML-тегов вместе с атрибутами
- toStr() : string
- Convert $str to the string
- translate() : string
- Translation from russian to $targetLanguageCode
- transliteration() : string
- Transliteration
- trimUri() : string
- Cut first and last slash
- ucfirst() : string
- ucfirst for utf-8 string
- xml() : string
- Correct string to XML legal characters http://www.w3.org/TR/xml/#charsets
- _callbackChr() : mixed
- Callback function
- _getInitialsReduce() : string
- Get initial reduce
- _idnOrd() : bool
- for idnToAscii()
- _stripTagsCallback() : mixed
- stripTags() callback
Properties
$_aDisabledAttributes
Array for _stripTagsCallback()
protected
static array<string|int, mixed>
$_aDisabledAttributes
= array()
$_decimalSeparator
Decimal separator.
protected
static null|string
$_decimalSeparator
= \NULL
$_detectedLng
Last detected language code by self::translate()
protected
static null|string
$_detectedLng
= \NULL
$_xmlIllegalCharacters
List of illegal characters
protected
static array<string|int, mixed>
$_xmlIllegalCharacters
= \NULL
Methods
br2nl()
Convert HTML line breaks to newlines in a string
public
static br2nl(string $string[, string $lineBreak = PHP_EOL ]) : string
Parameters
- $string : string
-
string
- $lineBreak : string = PHP_EOL
-
line break character
Return values
stringconvertDimension()
Convert dimension
public
static convertDimension(mixed $from, string $to, mixed $value) : float
Parameters
- $from : mixed
- $to : string
- $value : mixed
Return values
floatconvertHtmlToText()
Convert html to text
public
static convertHtmlToText(string $text) : string
Parameters
- $text : string
Return values
stringconvertSizeToBytes()
Convert size from 10M to bytes
public
static convertSizeToBytes(string $str) : int
Parameters
- $str : string
-
e.g. 10M
Return values
intconvertSpaces()
Converts different kinds of spaces (U+2002 - U+200D) to regular space
public
static convertSpaces(string $str) : string
Parameters
- $str : string
Return values
stringconvertTextToHtml()
Convert text to html
public
static convertTextToHtml(string $text) : string
Parameters
- $text : string
Return values
stringconvertWeight()
Convert weight
public
static convertWeight(mixed $from, string $to, mixed $value) : float
Parameters
- $from : mixed
- $to : string
- $value : mixed
Return values
floatcreateColor()
Get Color By Entity ID
public
static createColor(int $id[, int $maxColor = 210 ]) : string
Parameters
- $id : int
-
Entity ID
- $maxColor : int = 210
-
Max color, 0-255, default 210
Return values
string —HEX color, e.g. #B781AF
cut()
Cut string to defined lenght
public
static cut(string $string[, int $maxLen = 15 ]) : string
Parameters
- $string : string
-
source string
- $maxLen : int = 15
-
lenght
Return values
stringcutSentences()
Укорачивает описание до заданного количества символов, оставляя целое число предложений
public
static cutSentences(string $text[, int $maxLen = 255 ]) : string
Parameters
- $text : string
-
- text
- $maxLen : int = 255
-
- max ken
- max ken
Return values
stringcutWords()
Cut length of words in a string
public
static cutWords(string $string, int $maxLen) : string
Parameters
- $string : string
-
source string
- $maxLen : int
-
word lenght
Return values
stringdeclension()
Получение существительного в форме, соответствующей числу
public
static declension(int $int, string $word, array<string|int, mixed> $aEndings) : string
Parameters
- $int : int
-
число, с которым связано существительное
- $word : string
-
основа слова
- $aEndings : array<string|int, mixed>
-
массив окончаний слова
"; } ?>
Return values
stringdeclensionNumber()
Возвращает строку согласно падежам
public
static declensionNumber(int $number, string $nominative, $genitive_singular, $genitive_plural) : string
Parameters
- $number : int
-
number
- $nominative : string
-
Nominative case
- $genitive_singular :
-
Genitive singular case
- $genitive_plural :
-
Genitive plural case
Return values
stringdeleteIllegalCharacters()
Delete illegal characters
public
static deleteIllegalCharacters(string $string) : string
Parameters
- $string : string
Return values
stringendsWith()
String end with the specified string
public
static endsWith(string $haystack, string $needle) : bool
Parameters
- $haystack : string
- $needle : string
Return values
boolescapeJavascriptVariable()
Escaping apostrophe ('), slashes (\), 'script' and line breaks.
public
static escapeJavascriptVariable(string $str) : string
Parameters
- $str : string
-
source string
Return values
stringgenerateChars()
Get string of rand chars
public
static generateChars(mixed $number) : string
Parameters
- $number : mixed
Return values
stringgetDecimalSeparator()
Get Decimal Separator By Locale
public
static getDecimalSeparator() : string
Return values
stringgetHashes()
Метод очищает HTML от ненужных тегов, хеширует и возвращает массив хэшей слов
public
static getHashes(string $text[, array<string|int, mixed> $param = array() ]) : array<string|int, mixed>
Parameters
- $text : string
-
исходный текст;
- $param : array<string|int, mixed> = array()
-
массив дополнительных параметров
- $param['hash_function'] = 'md5' {'md5','crc32',''} используемая ХЭШ-функция;
Return values
array<string|int, mixed> —массив хэшей слов
getInitials()
public
static getInitials(mixed $fullName[, mixed $length = 2 ]) : mixed
Parameters
- $fullName : mixed
- $length : mixed = 2
getLastDetectedLanguageCode()
Get last detected language code by self::translate()
public
static getLastDetectedLanguageCode() : null|string
Return values
null|stringgetTextCount()
Convert count from int to K thousands, M million and B billion suffix, e.g. 102010 => 102K
public
static getTextCount(mixed $count) : string
Parameters
- $count : mixed
Return values
stringgetTextSize()
Convert size from bytes to kb, mb, etc
public
static getTextSize(mixed $size) : string
Parameters
- $size : mixed
Return values
stringgetXmlIllegalCharacters()
Get XML illegal characters
public
static getXmlIllegalCharacters() : array<string|int, mixed>
Return values
array<string|int, mixed>hex2darker()
Darker HEX color
public
static hex2darker(string $hex, mixed $opacity) : mixed
Parameters
- $hex : string
-
HEX color, e.g. #B781AF or #FF0
- $opacity : mixed
hex2hsl()
Convert HEX color to RGB or HSL
public
static hex2hsl(string $hex) : string
Parameters
- $hex : string
-
HEX color, e.g. #B781AF or #FF0
Return values
stringhex2ip()
Convert hexadecimal value into IP
public
static hex2ip(string $hex) : string
Parameters
- $hex : string
-
source value
Return values
stringhex2lighter()
Lighter HEX color
public
static hex2lighter(string $hex, mixed $opacity) : mixed
Parameters
- $hex : string
-
HEX color, e.g. #B781AF or #FF0
- $opacity : mixed
hex2rgba()
Convert HEX color to RGB or RGBA
public
static hex2rgba(string $hex[, mixed $opacity = NULL ]) : string
Parameters
- $hex : string
-
HEX color, e.g. #B781AF or #FF0
- $opacity : mixed = NULL
Return values
stringhideZeros()
Hide last zeros, e.g. '.00', (locale dependent)
public
static hideZeros(mixed $str) : string
Parameters
- $str : mixed
Return values
stringiconv()
Convert string to requested character encoding
public
static iconv(string $from_encoding, string $to_encoding, string|array<string|int, mixed> $mValue) : mixed
Parameters
- $from_encoding : string
-
The input charset.
- $to_encoding : string
-
The output charset, e.g. 'UTF-8'
- $mValue : string|array<string|int, mixed>
idnToAscii()
Encode to IDN ASCII https://www.ietf.org/rfc/rfc3492.txt
public
static idnToAscii(string $domain) : string
Parameters
- $domain : string
Return values
stringidnToUtf8()
Decode Punycode IDN https://www.ietf.org/rfc/rfc3492.txt
public
static idnToUtf8(string $domain) : string
Parameters
- $domain : string
Return values
stringip2hex()
Convert IP into hexadecimal value
public
static ip2hex(string $ip) : mixed
Parameters
- $ip : string
-
IP
lcfirst()
lcfirst for utf-8 string
public
static lcfirst(string $str) : string
Parameters
- $str : string
-
source string
Return values
stringltrimUri()
Cut first slash
public
static ltrimUri(mixed $uri) : string
Parameters
- $uri : mixed
Return values
stringremoveBOM()
Remove BOM
public
static removeBOM(string $str) : string
Parameters
- $str : string
Return values
stringremoveEmoji()
Remove emoji (UTF8 4 Byte characters)
public
static removeEmoji(string $str) : string
Parameters
- $str : string
-
source string
Return values
stringrgb2hex()
Convert RGB to HEX color
public
static rgb2hex(array<string|int, mixed> $array) : string
Parameters
- $array : array<string|int, mixed>
Return values
string —HEX color, e.g. #B781AF
rtrimUri()
Cut last slash
public
static rtrimUri(mixed $uri) : string
Parameters
- $uri : mixed
Return values
stringsanitizePhoneNumber()
Sanitize phone numbers
public
static sanitizePhoneNumber(mixed $phone) : string
Parameters
- $phone : mixed
Return values
stringstartsWith()
String starts with the specified string
public
static startsWith(string $haystack, string $needle) : bool
Parameters
- $haystack : string
- $needle : string
Return values
boolstr2ncr()
Convert HTML entity to numeric character reference (NCR)
public
static str2ncr(string $str) : string
Parameters
- $str : string
-
source string
Return values
stringstringToSecret()
Mask parts of a string with the asterisk character
public
static stringToSecret(string $string[, int|null $visibleCount = NULL ]) : string
Parameters
- $string : string
- $visibleCount : int|null = NULL
Return values
stringstripTags()
Удаление HTML-тегов вместе с атрибутами
public
static stripTags(string $source[, string $allowedTags = '' ][, array<string|int, mixed> $aDisabledAttributes = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavaible', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragdrop', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterupdate', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmoveout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload') ]) : string
Parameters
- $source : string
-
Исходная строка
- $allowedTags : string = ''
-
Список разрешенных тегов, например, ""
- $aDisabledAttributes : array<string|int, mixed> = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavaible', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragdrop', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterupdate', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmoveout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload')
-
Массив запрещенных атрибутов тегов, например array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavaible', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragdrop', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterupdate', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmoveout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload')
Return values
stringtoStr()
Convert $str to the string
public
static toStr(mixed $mixed) : string
Parameters
- $mixed : mixed
Return values
stringtranslate()
Translation from russian to $targetLanguageCode
public
static translate(string $string[, string $targetLanguageCode = 'en' ]) : string
Parameters
- $string : string
-
source string
- $targetLanguageCode : string = 'en'
-
target language
Return values
stringtransliteration()
Transliteration
public
static transliteration(string $string) : string
Parameters
- $string : string
-
source string
Return values
stringtrimUri()
Cut first and last slash
public
static trimUri(mixed $uri) : string
Parameters
- $uri : mixed
Return values
stringucfirst()
ucfirst for utf-8 string
public
static ucfirst(string $str) : string
Parameters
- $str : string
-
source string
Return values
stringxml()
Correct string to XML legal characters http://www.w3.org/TR/xml/#charsets
public
static xml(string $string) : string
Parameters
- $string : string
Return values
string_callbackChr()
Callback function
protected
static _callbackChr(mixed $matches) : mixed
Parameters
- $matches : mixed
_getInitialsReduce()
Get initial reduce
protected
static _getInitialsReduce(string $str, string $item) : string
Parameters
- $str : string
- $item : string
Return values
string_idnOrd()
for idnToAscii()
protected
static _idnOrd(string $char[, int $index = 0 ][, int &$iBytes = NULL ]) : bool
Parameters
- $char : string
- $index : int = 0
- $iBytes : int = NULL
Return values
bool_stripTagsCallback()
stripTags() callback
protected
static _stripTagsCallback(mixed $matches) : mixed
Parameters
- $matches : mixed