Text

The Text helper file contains functions that assist in working with text strings.

chars

Convert special characters to HTML entities.

text_helper::chars('<b>Example</b>'); // &lt;b&gt;Example&lt;/b&gt;
text_helper::chars('&lt;b&gt;Example&lt;/b&gt;', false) // &lt;b&gt;Example&lt;/b&gt;
text_helper::chars('&lt;b&gt;Example&lt;/b&gt;'); // &amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;

entities

Convert all applicable characters to HTML entities.

text_helper::entities('<b>Example</b>');

decodeEntities

Decode all applicable entities to HTML characters.

text_helper::decodeEntities('&lt;b&gt;Example&lt;/b&gt;'); // <b>Example</b>

random

Create a random string.

text_helper::random(8); // T5w0RVrl (letters and numbers)
text_helper::random(8, 'alpha'); // YLHSKwGn (only letters)
text_helper::random(8, 'alnum_distinct'); // p6wgE2mz (no repeating characters next to each other)
text_helper::random(8, 'numeric'); // 63182078 (all numbers)
text_helper::random(8, 'nozero'); // 98394491 (all numbers without zeros)

truncate

Limit the number of characters in the string.

text_helper::truncate('The quick brown fox jumps over the lazy dog', 14); // The quick brow...
text_helper::truncate('The quick brown fox jumps over the lazy dog', 14, true); // The quick... (removes newline characters)
text_helper::truncate('The quick brown fox jumps over the lazy dog', 14, false, true); // The quick brown... (makes sure the last word is not cut short)
text_helper::truncate('The quick brown fox jumps over the lazy dog', 14, false, false, '...more'); // The quick brow...more (specify what to insert at the end)

camelize

Camelize text.

text_helper::camelize('The quick brown'); // theQuickBrown

slug

Create SEO friendly slug.

text_helper::slug('The quick brown'); // The-quick-brown

alternate

Alternative between strings.

text_helper::alternate('odd', 'even'); // first odd
text_helper::alternate('odd', 'even'); // even
text_helper::alternate('odd', 'even'); // odd