system/helperstext_helper.php

CodeIgniter

An open source application development framework for PHP

This content is released under the MIT License (MIT)

Copyright (c) 2014 - 2016, British Columbia Institute of Technology

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

word_limiter()

word_limiter(  $str,   $limit = 100,   $end_char = '…') : string

Word Limiter

Limits a string to X number of words.

Parameters

$str
$limit
$end_char

Returns

string

character_limiter()

character_limiter(  $str,   $n = 500,   $end_char = '…') : string

Character Limiter

Limits the string based on the character count. Preserves complete words so the character count may not be exactly as specified.

Parameters

$str
$n
$end_char

Returns

string

ascii_to_entities()

ascii_to_entities(string  $str) : string

High ASCII to Entities

Converts high ASCII text and MS Word special characters to character entities

Parameters

string $str

Returns

string

entities_to_ascii()

entities_to_ascii(  $str,   $all = TRUE) : string

Entities to ASCII

Converts character entities back to ASCII

Parameters

$str
$all

Returns

string

word_censor()

word_censor(  $str,   $censored,   $replacement = '') : string

Word Censoring Function

Supply a string and an array of disallowed words and any matched words will be converted to #### or to the replacement word you've submitted.

Parameters

$str
$censored
$replacement

Returns

string

highlight_code()

highlight_code(  $str) : string

Code Highlighter

Colorizes code strings

Parameters

$str

Returns

string

highlight_phrase()

highlight_phrase(string  $str, string  $phrase, string  $tag_open = '<mark>', string  $tag_close = '</mark>') : string

Phrase Highlighter

Highlights a phrase within a text string

Parameters

string $str

the text string

string $phrase

the phrase you'd like to highlight

string $tag_open

the openging tag to precede the phrase with

string $tag_close

the closing tag to end the phrase with

Returns

string

convert_accented_characters()

convert_accented_characters(string  $str) : string

Convert Accented Foreign Characters to ASCII

Parameters

string $str

Input string

Returns

string

word_wrap()

word_wrap(string  $str, integer  $charlim = 76) : string

Word Wrap

Wraps text at the specified character. Maintains the integrity of words. Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor will URLs.

Parameters

string $str

the text string

integer $charlim

= 76 the number of characters to wrap at

Returns

string

ellipsize()

ellipsize(  $str,   $max_length,   $position = 1,   $ellipsis = '&hellip;') : string

Ellipsize String

This function will strip tags from a string, split it at its max_length and ellipsize

Parameters

$str
$max_length
$position
$ellipsis

Returns

string —

ellipsized string