Function Summary
-
auto_link_text($text, $link = 'all', $href_options = array(), $truncate = false, $truncate_len = 35, $pad = '...')
Turns all urls and email addresses into clickable links. The +link+
parameter can limit what should be linked.
-
excerpt_text($text, $phrase, $radius = 100, $excerpt_string = '...', $excerpt_space = false)
Extracts an excerpt from the +text+ surrounding the +phrase+ with a number
of characters on each side determined by +radius+. If the phrase
isn't found, nil is returned. Ex: excerpt("hello my
world", "my", 3) => "...lo my wo..." If
+excerpt_space+ is true the text will only be truncated on whitespace,
never inbetween words.
-
string
highlight_text($text, $phrase, $highlighter = '<strong class="highlight">\\1</strong>')
Highlights the +phrase+ where it is found in the +text+ by surrounding it
like <strong class="highlight">I'm a highlight
phrase</strong>. The highlighter can be specialized by passing
+highlighter+ as single-quoted string with \1 where the phrase is supposed
to be inserted.
-
simple_format_text($text, $options = array())
Returns +text+ transformed into html using very simple formatting rules
-
strip_links_text($text)
Turns all links into words, like "<a
href="something">else</a>" to "else".
-
truncate_text($text, $length = 30, $truncate_string = '...', $truncate_lastspace = false)
Truncates +text+ to the length of +length+ and replaces the last three
characters with the +truncate_string+ if the +text+ is longer than
+length+.
-
wrap_text($text, $line_width = 80)
Word wrap long lines to line_width.
Function Details
-
auto_link_text ($text, $link = 'all', $href_options = array(), $truncate = false, $truncate_len = 35, $pad = '...')
Browse code
| $text |
|
| $link |
|
| $href_options |
|
| $truncate |
|
| $truncate_len |
|
| $pad |
|
Turns all urls and email addresses into clickable links. The +link+
parameter can limit what should be linked.
Options are :all (default), :email_addresses, and :urls. Example: auto_link("Go to http://www.symfony-project.com and say hello to fabien.potencier@example.com") => Go to <a href="http://www.symfony-project.com">http://www.symfony-project.com</a> and say hello to <a href="mailto:fabien.potencier@example.com">fabien.potencier@example.com</a>
-
excerpt_text ($text, $phrase, $radius = 100, $excerpt_string = '...', $excerpt_space = false)
Browse code
| $text |
|
| $phrase |
|
| $radius |
|
| $excerpt_string |
|
| $excerpt_space |
|
Extracts an excerpt from the +text+ surrounding the +phrase+ with a number
of characters on each side determined by +radius+. If the phrase
isn't found, nil is returned. Ex: excerpt("hello my
world", "my", 3) => "...lo my wo..." If
+excerpt_space+ is true the text will only be truncated on whitespace,
never inbetween words.
This might return a smaller radius than specified. excerpt("hello my world", "my", 3, "...", true) => "... my ..."
-
(string) highlight_text ($text, $phrase, $highlighter = '<strong class="highlight">\\1</strong>')
Browse code
| $text |
subject input to preg_replace.
|
| $phrase |
string or array of words to highlight
|
| $highlighter |
regex replacement input to preg_replace.
|
Highlights the +phrase+ where it is found in the +text+ by surrounding it
like <strong class="highlight">I'm a highlight
phrase</strong>. The highlighter can be specialized by passing
+highlighter+ as single-quoted string with \1 where the phrase is supposed
to be inserted.
N.B.: The +phrase+ is sanitized to include only letters, digits, and spaces before use.
-
simple_format_text ($text, $options = array())
Browse code
Returns +text+ transformed into html using very simple formatting rules
Surrounds paragraphs with <tt><p></tt> tags, and converts line breaks into <tt><br /></tt> Two consecutive newlines(<tt>\n\n</tt>) are considered as a paragraph, one newline (<tt>\n</tt>) is considered a linebreak, three or more consecutive newlines are turned into two newlines
-
strip_links_text ($text)
Browse code
Turns all links into words, like "<a
href="something">else</a>" to "else".
-
truncate_text ($text, $length = 30, $truncate_string = '...', $truncate_lastspace = false)
Browse code
| $text |
|
| $length |
|
| $truncate_string |
|
| $truncate_lastspace |
|
Truncates +text+ to the length of +length+ and replaces the last three
characters with the +truncate_string+ if the +text+ is longer than
+length+.
-
wrap_text ($text, $line_width = 80)
Browse code
Word wrap long lines to line_width.
|