Documentation

rex_string
in package

String utility class.

Table of Contents

Methods

buildAttributes()  : string
Returns a string by key="value" pair.
buildQuery()  : string
Generates URL-encoded query string.
highlight()  : string
Highlights a string.
normalize()  : string
Normalizes a string.
normalizeEncoding()  : string
Normalizes the encoding of a string (UTF8 NFD to NFC).
sanitizeHtml()  : string
Cleanup the given html string and removes possible malicious codes/markup.
size()  : int
Returns the string size in bytes.
split()  : array<string|int, string>
Splits a string by spaces (Strings with quotes will be regarded).
versionCompare()  : int|bool
versionSplit()  : array<int, string>
yamlDecode()  : array<string|int, mixed>
Parses YAML into a PHP array.
yamlEncode()  : string
Returns a string containing the YAML representation of $value.

Methods

buildAttributes()

Returns a string by key="value" pair.

public static buildAttributes(array<int|string, int|string|array<int, string>> $attributes) : string
Parameters
$attributes : array<int|string, int|string|array<int, string>>
Return values
string

buildQuery()

Generates URL-encoded query string.

public static buildQuery(array<string|int, mixed> $params[, string $argSeparator = '&' ]) : string
Parameters
$params : array<string|int, mixed>
$argSeparator : string = '&'
Return values
string

highlight()

Highlights a string.

public static highlight(string $string) : string
Parameters
$string : string
Return values
string

normalize()

Normalizes a string.

public static normalize(string $string[, string $replaceChar = '_' ][, string $allowedChars = '' ]) : string

Makes the string lowercase, replaces umlauts by their ascii representation (ä -> ae etc.), and replaces all other chars that do not match a-z, 0-9 or $allowedChars by $replaceChar.

Parameters
$string : string

Input string

$replaceChar : string = '_'

Character that is used to replace not allowed chars

$allowedChars : string = ''

Allowed character list

Return values
string

normalizeEncoding()

Normalizes the encoding of a string (UTF8 NFD to NFC).

public static normalizeEncoding(string $string) : string

On HFS+ filesystem (OS X) filenames are stored in UTF8 NFD while all other filesystems are using UTF8 NFC. NFC is more common in general.

Parameters
$string : string

Input string

Return values
string

sanitizeHtml()

Cleanup the given html string and removes possible malicious codes/markup.

public static sanitizeHtml(string $html) : string
Parameters
$html : string
Return values
string

size()

Returns the string size in bytes.

public static size(string $string) : int
Parameters
$string : string

String

Return values
int

Size in bytes

split()

Splits a string by spaces (Strings with quotes will be regarded).

public static split(string $string) : array<string|int, string>

Examples: "a b 'c d'" -> array('a', 'b', 'c d') "a=1 b='c d'" -> array('a' => 1, 'b' => 'c d')

Parameters
$string : string
Return values
array<string|int, string>

versionCompare()

public static versionCompare(string $version1, string $version2[, "="|"=="|"!="|"<>"|"<"|"<="|">"|">="|null $comparator = '<' ]) : int|bool
Parameters
$version1 : string
$version2 : string
$comparator : "="|"=="|"!="|"<>"|"<"|"<="|">"|">="|null = '<'
Tags
deprecated

since 5.10, use rex_version::compare instead

Return values
int|bool

versionSplit()

public static versionSplit(string $version) : array<int, string>
Parameters
$version : string
Tags
deprecated

since 5.10, use rex_version::split instead

Return values
array<int, string>

yamlDecode()

Parses YAML into a PHP array.

public static yamlDecode(string $value) : array<string|int, mixed>
Parameters
$value : string

YAML string

Tags
throws
rex_yaml_parse_exception
Return values
array<string|int, mixed>

yamlEncode()

Returns a string containing the YAML representation of $value.

public static yamlEncode(array<string|int, mixed> $value[, int $inline = 3 ]) : string
Parameters
$value : array<string|int, mixed>

The value being encoded

$inline : int = 3

The level where you switch to inline YAML

Return values
string

        
On this page

Search results