helpers/text – Kohana API 2.3 Documentation

system/helpers/text.php

Class: text_Core

class text_Core

Text helper class.


Methods

text_Core :: limit_words

public static function limit_words

Limits a phrase to a given number of words.

Parameters:

string str
phrase to limit words of
integer limit
(int 100) number of words to limit to
string end_char
(NULL) end character or entity

Return: string


text_Core :: limit_chars

public static function limit_chars

Limits a phrase to a given number of characters.

Parameters:

string str
phrase to limit characters of
integer limit
(int 100) number of characters to limit to
string end_char
(NULL) end character or entity
boolean preserve_words
(FALSE) enable or disable the preservation of words while limiting

Return: string


text_Core :: alternate

public static function alternate

Alternates between two or more strings.

Param: string strings to alternate between

Return: string


text_Core :: random

public static function random

Generates a random string of a given type and length.

Parameters:

string type
(string alnum) a type of pool, or a string of characters to use as the pool
integer length
(int 8) length of string to return

Return: string

Tutorial:

  • alnum - alpha-numeric characters
  • alpha - alphabetical characters
  • numeric - digit characters, 0-9
  • nozero - digit characters, 1-9
  • distinct - clearly distinct alpha-numeric characters

text_Core :: reduce_slashes

public static function reduce_slashes

Reduces multiple slashes in a string to single slashes.

Parameters:

string str
string to reduce slashes of

Return: string


text_Core :: censor

public static function censor

Replaces the given words with a string.

Parameters:

string str
phrase to replace words in
array badwords
words to replace
string replacement
(string #) replacement string
boolean replace_partial_words
(FALSE) replace words across word boundries (space, period, etc)

Return: string


text_Core :: similar

public static function similar

Finds the text that is similar between a set of words.

Parameters:

array words
words to find similar text of

Return: string


text_Core :: auto_link

public static function auto_link

Converts text email addresses and anchors into links.

Parameters:

string text
text to auto link

Return: string


text_Core :: auto_link_urls

public static function auto_link_urls

Converts text anchors into links.

Parameters:

string text
text to auto link

Return: string


text_Core :: auto_link_emails

public static function auto_link_emails

Converts text email addresses into links.

Parameters:

string text
text to auto link

Return: string


text_Core :: auto_p

public static function auto_p

Automatically applies

and
markup to text. Basically nl2br() on steroids.

Parameters:

string str
subject

Return: string


text_Core :: bytes

public static function bytes

Returns human readable sizes.

Parameters:

integer bytes
size in bytes
string force_unit
(NULL) a definitive unit
string format
(NULL) the return string format
boolean si
(TRUE) whether to use SI prefixes or IEC

See:

  • Based on original functions written by:
  • Aidan Lister: http://aidanlister.com/repos/v/function.size_readable.php
  • Quentin Zervaas: http://www.phpriot.com/d/code/strings/filesize-format/

Return: string


text_Core :: widont

public static function widont

Prevents widow words by inserting a non-breaking space between the last two words.

Parameters:

string str
string to remove widows from

See: http://www.shauninman.com/archive/2006/08/22/widont_wordpress_plugin

Return: string