October\Rain\Html\Helper

Overview

Helper methods that may be useful for processing HTML tasks


Public Methods

public static nameToArray()

public static nameToArray($string $string): array 

nameToArray converts a HTML named array string to a PHP array. Empty values are removed. HTML: user[location][city] PHP: ['user', 'location', 'city']

public static nameToDot()

public static nameToDot($string $string): string 

nameToDot converts a HTML named array string to a dot notated string. HTML: user[location][city] Dot: user.location.city

public static nameToId()

public static nameToId($string $string): string 

nameToId converts a HTML array string to an identifier string. HTML: user[location][city] Result: user-location-city

public static reduceNameHierarchy()

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

reduceNameHierarchy reduces the field name hierarchy depth by $level levels. 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.