RockLobsterInc\FormDataTree

dissolve_name() │ CF7 1.0

Returns components of the given name.

Хуков нет.

Возвращает

array. Single dimension array of name components.

Использование

dissolve_name( $name ): array;
$name(строка) (обязательный)
Field name, such as 'abc' or 'abc[de]'.

Код dissolve_name() CF7 6.2.4.1

function dissolve_name(string $name): array
{
    $name = strip_whitespaces($name);

    $s =
        '[\x09-\x0D\x20\xA0\x{1680}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}\x{FEFF}]*';

    $pattern =
        "/^" .
        "([a-z][0-9a-z:_-]*)" . // Core
        "((?:\[" .
        $s .
        "(?:[a-z][0-9a-z:_-]*|[0-9]*)" .
        $s .
        "\])*)" . // Layers
        '$/iu';

    if (!preg_match($pattern, $name, $matches)) {
        return [];
    }

    $core = $matches[1];
    $layers = $matches[2];

    preg_match_all("/\[(.*?)\]/u", $layers, $matches);

    $layers = array_map(static function (string $item) {
        return strip_whitespaces($item);
    }, $matches[1]);

    return [$core, ...$layers];
}