Class Jyxo_String
Base class for common string operations.
Methods summary
public static
string
|
#
cutWords( string $string, integer $length = 25, string $etc = '...' )
Trims all words in a string longer than given length. String is delimited by
whitespaces. If a word is trimmed, an "etc" is added at the end. Its length is
also considered.
Trims all words in a string longer than given length. String is delimited by
whitespaces. If a word is trimmed, an "etc" is added at the end. Its length is
also considered.
Parameters
- $string
string Processed string
- $length
integer Maximum word length
- $etc
string "etc" definition
Returns
string
|
public static
string
|
#
cut( string $string, integer $max = 50, string $etc = '...' )
Trims a string to given length. Trims at word boundaries (all
non-alphanumeric characters are considered delimiters). If the given string is
trimmed, an "etc" is added at the end. Its length is also considered.
Trims a string to given length. Trims at word boundaries (all
non-alphanumeric characters are considered delimiters). If the given string is
trimmed, an "etc" is added at the end. Its length is also considered.
Parameters
- $string
string Trimmed string
- $max
integer Maximum length
- $etc
string "etc" definition
Returns
string
|
public static
integer
|
#
crc( string $string )
Generates a crc checksum same on 32 and 64-bit platforms.
Generates a crc checksum same on 32 and 64-bit platforms.
Parameters
- $string
string Input string
Returns
integer
|
public static
string
|
#
random( integer $length )
Generates a random string of given length.
Generates a random string of given length.
Parameters
- $length
integer String length
Returns
string
|
public static
string
|
#
fixLineEnding( string $string, string $lineEnd = "\n" )
Fixes and unifies line endings in a string.
Fixes and unifies line endings in a string.
Parameters
- $string
string String to fix
- $lineEnd
string Desired line ending
Returns
string
|
public static
string
|
#
obfuscateEmail( string $email, string $comment = false )
Obfuscates an email address.
Obfuscates an email address.
Parameters
- $email
string Email address
- $comment
string Put a comment into the address
Returns
string
|
public static
string
|
#
lcfirst( string $string )
Converts first character of a string to lowercase. Works correctly with
multibyte encodings.
Converts first character of a string to lowercase. Works correctly with
multibyte encodings.
Parameters
- $string
string Input string
Returns
string
|
public static
string
|
#
escape( string $string, integer $quoteStyle = ENT_QUOTES, boolean $doubleEncode = false )
Htmlspecialchars function alias with some parameters automatically set.
Htmlspecialchars function alias with some parameters automatically set.
Parameters
- $string
string Input string
- $quoteStyle
integer Quote style
- $doubleEncode
boolean Prevent from double encoding
Returns
string
|
public static
string
|
#
formatBytes( float $size, string $decimalPoint = ',', string $thousandsSeparator = ' ' )
Converts given size in bytes to kB, MB, GB, TB or PB and appends the
appropriate unit.
Converts given size in bytes to kB, MB, GB, TB or PB and appends the
appropriate unit.
Parameters
- $size
float Input size
- $decimalPoint
string Decimal point
- $thousandsSeparator
string Thousands separator
Returns
string
|