private function getSegments($name)
    {
        if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
            $segments = [$m['base']];
            while (!empty($m['extra'])) {
                $extra = $m['extra'];
                if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
                    $segments[] = $m['segment'];
                } else {
                    $segments[] = $extra;
                }
            }

            return $segments;
        }

        return [$name];
    }
private function getSegments($name)
    {
        if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
            $segments = [$m['base']];
            while (!empty($m['extra'])) {
                $extra = $m['extra'];
                if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
                    $segments[] = $m['segment'];
                } else {
                    $segments[] = $extra;
                }
            }

            return $segments;
        }

        return [$name];
    }
private function getSegments ( $ name ) { if ( preg_match ( '/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/' , $ name , $ m ) ) { $ segments = [ $ m [ 'base' ] ] ; while ( ! empty ( $ m [ 'extra' ] ) ) { $ extra = $ m [ 'extra' ] ; if ( preg_match ( '/^\[(?P<segment>.*?)\](?P<extra>.*)$/' , $ extra , $ m ) ) { $ segments [ ] = $ m [ 'segment' ] ; } else { $ segments [ ] = $ extra ; } } return $ segments ; } return [ $ name ] ; }
Splits a field name into segments as a web browser would do.

getSegments('base[foo][3][]') = ['base', 'foo, '3', ''];

@param string $name The name of the field

@return string[] The list of segments
Splits a field name into segments as a web browser would do .