\cge_string

A set of string utility functions.

Summary

Methods
Properties
Constants
mask_string()
word_limiter()
str_to_bytes()
is_smarty_safe()
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, int $numchars, string $mask) : string

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

Parameters

string $instr

The input string

int $numchars

The number of characters to mask

string $mask

The mask character

Returns

string

word_limiter()

word_limiter(string $str, int $limit, string $end_char) : string

Truncate the input string after N words.

Parameters

string $str

The input string

int $limit

The word limit

string $end_char

How to terminate the output string

Returns

string

str_to_bytes()

str_to_bytes(string $val) : int

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

int

is_smarty_safe()

is_smarty_safe( $string) : bool

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

Returns

bool