Strings Module

String helper functions. Call these helper functions from $core->strings

ends_with($source, $end, $case_sensitive = true)

Returns TRUE if the $source string ends with the $end string. By default this function is case sensitive. Pass FALSE to $case_sensitive to use it case insensitive.

filter($source, $filter_characters, $case_sensitive = true)

Filters the $source string to only include characters in the $filter_characters string. This function returns a new string that only includes the desired characters. By default this function is case sensitive. Pass FALSE to $case_sensitive to use it case insensitive.

filter_alpha($source)

Returns a string that only contains the alpha characters from the $source string.

filter_digits($source)

Returns a string that only contains the numeric characters from the $source string.

filter_float($source)

Returns a string that only contains the characters necessary to represent a floating point number from the $source string. Those characters include: '0123456789.-'

make_safe($value)

Makes a string safe for use in a SQL query by HTML encoding single and double quote characters.

object_to_string($object, $brief_properties = array(), $hidden_properties = array())

Create a string representation of an object with the ability to hide properties that will expand into other large objects in the string output. Pass a list of properties to only show as [Other Object] in the resulting string in $brief_properties. Pass a list of properties to hide in the resulting string in $hidden_properties.

parse_list($source, $delimiter, $exclude_empty_items = true)

Parses the $source string variable as a list which is returned in an array. The list items are searched for by the $delimiter separator. Pass FALSE for $exclude_empty_items to include any empty items from the list in the resulting array. This function returns FALSE if there are no items found.

substr_contained_within($source, $contain_start, $contain_end = false)

Returns a substring from within $source that is surrounded by the strings in $contain_start and $contain_end. If $contain_end is not specified it will use the same value as $contain_start. If the containing strings can not be found in $source then this function returns FALSE.