Class for string actions

category OSS
package OSS_String
copyright Copyright (c) 2007 - 2012, Open Source Solutions Limited, Dublin, Ireland
license New BSD License

 Methods

If the parameter is an array, then runs html_entity_decode() on every item of it, recursively.

htmlEntityDecode(mixed $input) : array | string
Static

Otherwise treats the input as a string, and runs html_entity_decode() on it. If the input is an object, then the return value will be an array of the public object properties. The return value is either a string or an array.

Parameters

$input

mixed

Returns

arraystring

The Unicode version of str_replace().

mb_str_replace(string $needle, string $replacement, string $haystack) : string
Static

Parameters

$needle

string

The string portion to replace in the haystack

$replacement

string

The replacement for the string portion

$haystack

string

The haystack

Returns

string

The Unicode version of ucfirst().

mb_ucfirst(string $string, string $encoding) : string
Static

Parameters

$string

string

the input string

$encoding

string

default null the character encoding, if omitted the the PHP internal encoding is used

Returns

string

The Unicode version of ucwords().

mb_ucwords(string $string, string $encoding) : string
Static

Parameters

$string

string

the input string

$encoding

string

default null the character encoding, if omitted the the PHP internal encoding is used

Returns

string

Removes any diacritic, accent and combining characters from the string.

normalise(string $input, bool $keepSpaces) : string
Static

These settings should be set for working results: mb_language('uni'); mb_internal_encoding('UTF-8'); setlocale(LC_ALL, "en_IE.utf8"); //or any other locale, as long as it's utf8

Parameters

$input

string

the original input string

$keepSpaces

bool

By default is false and it will remove spaces from string. Then it is set true it will keep spaces in string.

Returns

string

Generates a random string.

random(int $length, bool $lowerCase, bool $upperCase, bool $numbers, string $additional, string $exclude) : string
Static

Parameters

$length

int

The length of the random string we want to generate. Default: 16

$lowerCase

bool

If true then lowercase characters will be used. Default: true

$upperCase

bool

If true then uppercase characters will be used. Default: true

$numbers

bool

If true then numbers will be used. Default: true

$additional

string

These characters also will be used. Default: ''

$exclude

string

These characters will be excluded. Default: '1iIl0O'

Returns

string

Returns with a random string using the characters found in $charSet only.

randomFromSet(string $charSet, int $length) : string
Static

Parameters

$charSet

string

$length

int

Returns

string

Generates a random MAC address.

randomMacAddress(bool $upperCase) : string
Static

Parameters

$upperCase

bool

default false

Returns

string

Creates a random password string of a given length.

randomPassword(int $length) : string
Static

Not the fastest way of generating random passwords, but ensures that it contains both lowercase and uppercase letters and digits, so complies with our password strength "policy".

Some letters are excluded from the character set: 1, 0, O, I, l

Parameters

$length

int

The length of the password to be generated.

Returns

stringThe password string.

Generates a random salt.

salt(int $len) : string
Static

Parameters

$len

int

Length of return salt.

Returns

string

If the parameter is an array, then runs stripslashes() on every item of it, recursively.

stripSlashes(mixed $input) : array | string
Static

Otherwise treats the input as a string, and runs stripslashes() on it. If the input is an object, then the return value will be an array of the public object properties. The return value is either a string or an array.

Parameters

$input

mixed

Returns

arraystring

Takes a string, converts it to lowercase and creates a valid file name from it by replacing any character by an underscore which is not [0-9a-z] (so only the standard neolatin (english) alphabet is supported), then replaces any consecutive underscores with only one underscore.

toValidFieldName(string $string) : string
Static

Leading and trailing underscores are also removed.

Parameters

$string

string

Returns

string