Documentation

Helper
in package

Methods that may be useful for processing HTML tasks

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

nameToArray()  : array<string|int, mixed>
Converts a HTML named array string to a PHP array. Empty values are removed.
nameToId()  : string
Converts a HTML array string to an identifier string.
reduceNameHierarchy()  : string
Reduces the field name hierarchy depth by $level levels.

Methods

nameToArray()

Converts a HTML named array string to a PHP array. Empty values are removed.

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

HTML: user[location][city] PHP: ['user', 'location', 'city']

Parameters
$string :

String to process

Return values
array<string|int, mixed>

nameToId()

Converts a HTML array string to an identifier string.

public static nameToId( $string) : string

HTML: user[location][city] Result: user-location-city

Parameters
$string :

String to process

Return values
string

reduceNameHierarchy()

Reduces the field name hierarchy depth by $level levels.

public static reduceNameHierarchy(string $fieldName, int $level) : string

country[city][0][street][0] turns into country[city][0] when reduced by 1 level; country[city][0][street][0] turns into country when reduced by 2 levels; etc.

Parameters
$fieldName : string
$level : int
Return values
string

Search results