text2words
Description
Chops a string of text into individual words and prepares them to be inserted into (or searched from) the database.
Syntax
mixed text2words (string $text, int $max_chars[, bool $encrypt])
Parameter $text
Expected type: String
Description: The text that should be split up into words
Parameter $max_chars
Expected type: Integer
Description: The maximum number of characters to use for each word (default is 20)
Parameter $encrypt
Expected type: Boolean
Description: Whether or not to encrypt the words (default is false)
Return value
Expected type: Mixed
Description:
Possible types | |
Allowed values | Description |
Array of Integers | A unique array of integers, each one corresponding to and uniquely identifying an inserted word (if $encrypt is true) |
Array | An array of the inserted words (if $encrypt is false) |
Notes
- Strips entities and non-word characters (spaces, tabs, newlines, carriage returns, punctuation symbols)
- Replaces any remaining HTML entities with their appropriate character
- Uses crypt() to encrypt the words if $encrypt is true
- $max_chars is the maximum number of characters each word should be
- If $encrypt is true, the returned array will contain integers that can be used to figure out what each word was
- If $encrypt is false, the returned array will simply contain all the words that were inserted