FUEL CMS User Guide : Version 1.4


My String Helper

This helper extends CI's string helper

Function Reference [+]

eval_string('$str', [$vars=array()])

Evaluates a strings PHP code. Used especially for outputing FUEL page data.

Returns

string

Parameters

(string) $str string to evaluate
(mixed) $vars variables to pass to the string

pluralize('$num', ['$str'=''], ['$plural'='s'])

Add an s to the end of s string based on the number.

Returns

string

Parameters

(int) $num number to compare against to determine if it needs to be plural
(string) $str string to evaluate
(string) $plural plural value to add

strip_whitespace('$str')

Strips extra whitespace from a string.

Returns

string

Parameters

(string) $str 

trim_multiline('$str')

Trims extra whitespace from the end and beginning of a string on multiple lines.

Returns

string

Parameters

(string) $str 

smart_ucwords('$str', [$exceptions=array([0]=>of[1]=>the)])

Converts words to title case and allows for exceptions.

Returns

string

Parameters

(string) $str string to evaluate
(mixed) $exceptions variables to pass to the string

zap_gremlins('$str', ['$replace'=''])

Removes "Gremlin" characters. (hidden control characters that the remove_invisible_characters function misses).

Returns

string

Parameters

(string) $str string to evaluate
(string) $replace the value used to replace a gremlin

strip_javascript('$str')

Removes javascript from a string.

Returns

string

Parameters

(string) $str string to remove javascript

safe_htmlentities('$str', ['$protect_amp'=TRUE])

Safely converts a string's entities without encoding HTML tags and quotes.

Returns

string

Parameters

(string) $str string to evaluate
(boolean) $protect_amp determines whether to encode the ampersand or not

php_to_template_syntax('$str', ['$engine'=NULL])

Convert PHP syntax to templating syntax.

Returns

string

Parameters

(string) $str string to evaluate

parse_template_syntax('$str', [$vars=array()], ['$engine'=NULL], [$config=array()])

Convert string to templating syntax.

Returns

string

Parameters

(string) $str string to evaluate
(array) $vars variables to parse with string
(string) $engine the templating engine to use
(array) $config an array of configuration variables like compile_dir, delimiters, allowed_functions, refs and data