Text class

The following sections explain each method of the class.

strip_tags_with_content (from v2.5.0)


public static string strip_tags_with_content (string $str, array $removeContentTags = array('table'))

By means of the method strip_tags_with_content can HTML tags, remove its contents. The normal PHP function strip_tags away here only during the day, but leaves behind the content. For some HTML tags but this is very useless, such as in HTML tables.

Parameter list
str

The text with the HTML tags as content, which should be removed.

removeContentTags

In the array one specifies which HTML tags are to be removed and its contents. If this tag is not specified, only the HTML is removed the day itself and the content remains.


word_limiter


public static string word_limiter (string $str, int $limit = 100, string $suffix = '...')

Limited a set to a specific number of words. The residue is replaced by a so-called suffix. This means that text block is appended at the end of the shortened set.

Parameter list
str

The string whose content is to be reduced to a specific word limit.

limit

The maximum number of words that may occur in the string. From then be reduced. By default set to 100.

suffix

The suffix should be attached at the end of the sentence. "..." Put on by default.


truncate


public static string truncate (string $string, int $limit, string $suffix = '...')

Reduces a string to a certain number of characters down and replace the rest by a suffix.

Parameter list
string

The string to be truncated to a certain number of characters.

limit

The maximum number of characters may have the string.

suffix

The suffix to the rest of the string, which is removed, replaced.


getCharacterEncoding (from v2.4.0)


public static string|bool getCharacterEncoding (string $str)

Determines the character encoding of a string.

Parameter list
str

The whose character encoding string to be determined.


convertToUTF8 (from v2.4.0)


public static string convertToUTF8 (string $str, string $encoding)

Converts a string into a UTF-8 string.

Parameter list
str

The string to be Converted to the character encoding UTF-8.

encoding

The original character encoding of the string.


word_censor


public static string word_censor (string $str, array $censored, string $replacement = '')

Censored certain words from a string and replaces it with another string.

Parameter list
str

The string whose content is to be searched on Censored words.

censored

The array of censored words.

replacement

The string whereby the censored words to be replaced.


highlight_code


public static string highlight_code (string $str)

Highlighted PHP code in a string

Parameter list
str

The content whose string is to be searched for PHP tags and then this Highlighted.


random_string


public static string random_string (string $type = 'normal', int $length = 10)

Returns a random string in a certain length.

Parameter list
type

The type of string is to come back. The following are available:

  • normal oder md5 An MD5 hash from the current timestamp and a random UNIQ ID
  • alnum An alphanumeric string consisting of being able to following signs: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  • numeric A numeric string consisting of being able to following signs: 0123456789
  • nozero A numeric string consisting can from the following characters: 123456789
  • alpha A string consisting of being able to following signs: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  • sha1 A SHA1 hash of the current timestamp and a random UNIQ ID


reduce_double_slashes


public static string reduce_double_slashes (string $str)

Removes duplicate slashes of a URL string.

Parameter list
str

The string whose content is to be checked for duplicate slashes. An example would be the following URL:
http://www.google.de//meineSuche
That string would be following after the function call:
http://www.google.de/meineSuche


strip_quotes


public static string strip_quotes (string $str)

Remove single and double quotes from a string.

Parameter list
str

The content whose string is to be searched for single and double quotes.


trim_slashes


public static string trim_slashes (string $str)

Removed at the beginning and at the end of each string Slash.

Parameter list
str

The slashes the string to be removed at the beginning and at the end.