\cge_string

A set of string utility functions.

Summary

Methods
Properties
Constants
mask_string()
word_limiter()
str_to_bytes()
is_smarty_safe()
to_float()
to_string()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

mask_string()

mask_string(string  $instr, integer  $numchars, string  $mask = '*') : string

A simple utility function to mask the first N characters of an input string

Parameters

string $instr

The input string

integer $numchars

The number of characters to mask

string $mask

The mask character

Returns

string

word_limiter()

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

Truncate the input string after N words.

Parameters

string $str

The input string

integer $limit

The word limit

string $end_char

How to terminate the output string

Returns

string

str_to_bytes()

str_to_bytes(string  $val) : integer

Given an input string in the format of ###[GgMmKk] convert it into a byte count.

Each kilobyte is 1024 butes. Each megabyte is 1024 kilobytes. And each Gigabyte is 1024 megabytes.

Parameters

string $val

Returns

integer

is_smarty_safe()

is_smarty_safe(string  $string) : boolean

Test that the string contains characters that are safe for smarty variables.

i.e: underscores, and alphanumerics, and starts with an underscore and/or alphabetic.

Parameters

string $string

Returns

boolean

to_float()

to_float(string  $in) : float

Convert a locale specific string to a float

Parameters

string $in

The float value to convert.

Returns

float

to_string()

to_string(float  $in) : string

Convert a float to a string in locale specific format.

Parameters

float $in

Returns

string