Prado\I18N\core\ChoiceFormat::parse PHP Метод

parse() публичный Метод

Parse a choice string and get a list of sets and a list of strings corresponding to the sets.
public parse ( $string ) : array
Результат array array($sets, $strings)
    function parse($string)
    {
        $n = preg_match_all($this->parse, $string, $matches, PREG_OFFSET_CAPTURE);
        $sets = array();
        foreach ($matches[1] as $match) {
            $sets[] = $match[0];
        }
        $offset = $matches[0];
        $strings = array();
        for ($i = 0; $i < $n; $i++) {
            $len = strlen($offset[$i][0]);
            $begin = $i == 0 ? $len : $offset[$i][1] + $len;
            $end = $i == $n - 1 ? strlen($string) : $offset[$i + 1][1];
            $strings[] = substr($string, $begin, $end - $begin);
        }
        return array($sets, $strings);
    }