Метод | Описание | |
---|---|---|
basename ( string $path, string $suffix = '' ) : string | Returns the trailing name component of a path. | |
byteLength ( string $string ) : integer | Returns the number of bytes in the given string. | |
byteSubstr ( string $string, integer $start, integer $length = null ) : string | Returns the portion of string specified by the start and length parameters. | |
countWords ( string $string ) : integer | Counts words in a string | |
dirname ( string $path ) : string | Returns parent directory's path. | |
endsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean | Check if given string ends with specified substring. | |
explode ( string $string, string $delimiter = ',', mixed $trim = true, boolean $skipEmpty = false ) : array | Explodes string into array, optionally trims values and skips empty ones | |
startsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean | Check if given string starts with specified substring. | |
truncate ( string $string, integer $length, string $suffix = '...', string $encoding = null, boolean $asHtml = false ) : string | Truncates a string to the number of characters specified. | |
truncateWords ( string $string, integer $count, string $suffix = '...', boolean $asHtml = false ) : string | Truncates a string to the number of words specified. |
Метод | Описание | |
---|---|---|
truncateHtml ( string $string, integer $count, string $suffix, string | boolean $encoding = false ) : string | Truncate a string while preserving the HTML. |
public static byteLength ( string $string ) : integer | ||
$string | string | the string being measured for length |
Результат | integer | the number of bytes in the given string. |
public static byteSubstr ( string $string, integer $start, integer $length = null ) : string | ||
$string | string | the input string. Must be one character or longer. |
$start | integer | the starting position |
$length | integer | the desired portion length. If not specified or `null`, there will be no limit on length i.e. the output will be until the end of the string. |
Результат | string | the extracted part of string, or FALSE on failure or an empty string. |
public static countWords ( string $string ) : integer | ||
$string | string | |
Результат | integer |
public static endsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean | ||
$string | string | Input string to check |
$with | string | Part to search inside of the $string. |
$caseSensitive | boolean | Case sensitive search. Default is true. When case sensitive is enabled, $with must exactly match the ending of the string in order to get a true value. |
Результат | boolean | Returns true if first input ends with second input, false otherwise |
public static explode ( string $string, string $delimiter = ',', mixed $trim = true, boolean $skipEmpty = false ) : array | ||
$string | string | String to be exploded. |
$delimiter | string | Delimiter. Default is ','. |
$trim | mixed | Whether to trim each element. Can be: - boolean - to trim normally; - string - custom characters to trim. Will be passed as a second argument to `trim()` function. - callable - will be called for each value instead of trim. Takes the only argument - value. |
$skipEmpty | boolean | Whether to skip empty strings between delimiters. Default is false. |
Результат | array |
public static startsWith ( string $string, string $with, boolean $caseSensitive = true ) : boolean | ||
$string | string | Input string |
$with | string | Part to search inside the $string |
$caseSensitive | boolean | Case sensitive search. Default is true. When case sensitive is enabled, $with must exactly match the starting of the string in order to get a true value. |
Результат | boolean | Returns true if first input starts with second input, false otherwise |
public static truncate ( string $string, integer $length, string $suffix = '...', string $encoding = null, boolean $asHtml = false ) : string | ||
$string | string | The string to truncate. |
$length | integer | How many characters from original string to include into truncated string. |
$suffix | string | String to append to the end of truncated string. |
$encoding | string | The charset to use, defaults to charset currently used by application. |
$asHtml | boolean | Whether to treat the string being truncated as HTML and preserve proper HTML tags. This parameter is available since version 2.0.1. |
Результат | string | the truncated string. |
public static truncateWords ( string $string, integer $count, string $suffix = '...', boolean $asHtml = false ) : string | ||
$string | string | The string to truncate. |
$count | integer | How many words from original string to include into truncated string. |
$suffix | string | String to append to the end of truncated string. |
$asHtml | boolean | Whether to treat the string being truncated as HTML and preserve proper HTML tags. This parameter is available since version 2.0.1. |
Результат | string | the truncated string. |