Documentation

Text


The text helper is a set of methods to help with the manipulation of strings.


translitIt(string $str)


Translit function ua,ru => latin


echo Text::translitIt('Привет');

trimSlashes(string $str)


Removes any leading and traling slashes from a string


echo Text::trimSlashes('some text here/');

strpSlashes(string $str)


Removes slashes contained in a string or in an array


echo Text::strpSlashes('some \ text \ here');

stripQuotes(string $str)


Removes single and double quotes from a string


echo Text::stripQuotes('some "text" here');

quotesToEntities(string $str)


Convert single and double quotes to entities


echo Text::quotesToEntities('some "text" here');

random([string $type = 'alnum', [string $length = 16]])


Creates a random string of characters.


// Echo's 7GdtAfrIeB2i1PwT
echo Text::random();
// Echo's 886522129
echo Text::random('basic');
// Echo's eeae4b78d203ed75c424db651d025f26
echo Text::random('unique');
// Echo's 8f520ed29e09d569ae28cf2d404a3108a68b6da1
echo Text::random('sha1');
// Echo's olxCWLqexWebYXHI
echo Text::random('alpha');
// Echo's 0072154088176443
echo Text::random('numeric');
// Echo's 9926755998921531
echo Text::random('nozero');
// Echo's WT3AMVUJWCLHC9XM
echo Text::random('distinct');
// Echo's fa2faabc370a36bc
echo Text::random('hexdec');

cut(string $str, integer$length, [string $cut_msg = null])


Cut string


echo Text::cut('Some text here', 5);

lowercase(string $str)


Lowercase


echo Text::lowercase('Some text here');

uppercase(string $str)


Uppercase


echo Text::uppercase('Some text here');

length(string $str)


Get length


echo Text::length('Some text here');

lorem([integer $num = 1])


Create a lorem ipsum text


echo Text::lorem(2);

right(string $str, integer$num)


Extract the last `$num` characters from a string.


echo Text::right('Some text here', 4);

left(string $str, integer$num)


Extract the first `$num` characters from a string.


echo Text::left('Some text here', 4);

nl2br(string $str, [boolean $xhtml = true])


Replaces newline with
or
.


echo Text::nl2br("Some \n text \n here");

br2nl(string $str)


Replaces
and
with newline.


echo Text::br2nl("Some 
text
here");

ampEncode(string $str)


Converts & to & amp;


echo Text::ampEncode("M&CMS;");

ampDecode(string $str)


Converts & amp; to &.


echo Text::ampDecode("M& amp;CMS");

toHtml(string $str)


Convert plain text to html


echo Text::toHtml('test');