Parses response to 'players' command into structure
@param  string &$st Data
@return array       Structure
338782
public static function parsePlayers(&$st)
    {
        $playersn = Binary::getByte($st);
        $players = [];
        for ($i = 1; $i < $playersn; ++$i) {
            $n = Binary::getByte($st);
            $name = Binary::getString($st);
            $score = Binary::getDWord($st, true);
            if (mb_orig_strlen($st) === 0) {
                break;
            }
            $u = unpack('f', mb_orig_substr($st, 0, 4));
            $st = mb_orig_substr($st, 4);
            $seconds = $u[1];
            if ($seconds === -1) {
                continue;
            }
            $players[] = [
                'name' => Encoding::toUTF8($name),
                'score' => $score,
                'seconds' => $seconds,
                'joinedts' => microtime(true) - $seconds,
                'spm' => $score / ($seconds / 60),
            ];
        }
        return $players;
    }
732186
protected function getTeam($t)
    {
        $teamInfo = (array)$t;
        $team = new Team();
        $fields = array_keys($teamInfo);
        foreach ($fields as $field) {
            // I hope, that API-response will be changed and players_ids, leagues_ids will become arrays
            if (preg_match('/^player_\d+_account_id$/', $field)) {
                $team->addPlayerId($teamInfo[$field]);
                continue;
            }
            if (preg_match('/^league_id_\d+$/', $field)) {
                $team->addLeagueId($teamInfo[$field]);
                continue;
            }
            $team->set($field, (string)$teamInfo[$field]);
        }
        return $team;
    }
264573
function parse($str) {
		preg_match_all('/(\w+|\*)\h*=\h*(?:\[(.+?)\]|(.+?))(?=,|$)/',
			$str,$pairs,PREG_SET_ORDER);
		$out=[];
		foreach ($pairs as $pair)
			if ($pair[2]) {
				$out[$pair[1]]=[];
				foreach (explode(',',$pair[2]) as $val)
					array_push($out[$pair[1]],$val);
			}
			else
				$out[$pair[1]]=trim($pair[3]);
		return $out;
	}
836203
private function parse_body(&$body)
    {
        // Mail_mimeDecode need \r\n end-line, but gpg may return \n
        $body = preg_replace('/\r?\n/', "\r\n", $body);

        // parse the body into structure
        $struct = rcube_mime::parse_message($body);

        return $struct;
    }
1209233
public function parseStringMetadata($str)
    {
        $info = array();
        if (0!==preg_match('~^\[([^\]]+)\]~i', $str, $matches)) {
            $str = str_replace($matches[0], '', $str);
            $types = $matches[1];
            $types_items = explode(';', $types);
            foreach ($types_items as $item) {
                $parts = explode(':', $item);
                if (count($parts)>1) {
                    $info[$parts[0]] = $parts[1];
                } else {
                    $info[] = $parts[0];
                }
            }
        }
        return array($str, $info);
    }
228198
private function _parse_sections($str, $media_queries = array())
    {
        // Pre-process: collapse all whitespace and strip whitespace around '>',
        // '.', ':', '+', '#'

        $patterns = array("/[\\s\n]+/", "/\\s+([>.:+#])\\s+/");
        $replacements = array(" ", "\\1");
        $str = preg_replace($patterns, $replacements, $str);
        $DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();

        $sections = explode("}", $str);
        if ($DEBUGCSS) print '[_parse_sections';
        foreach ($sections as $sect) {
            $i = mb_strpos($sect, "{");
            if ($i === false) { continue; }

            //$selectors = explode(",", mb_substr($sect, 0, $i));
            $selectors = preg_split("/,(?![^\(]*\))/", mb_substr($sect, 0, $i),0, PREG_SPLIT_NO_EMPTY);
            if ($DEBUGCSS) print '[section';

            $style = $this->_parse_properties(trim(mb_substr($sect, $i + 1)));

            // Assign it to the selected elements
            foreach ($selectors as $selector) {
                $selector = trim($selector);

                if ($selector == "") {
                    if ($DEBUGCSS) print '#empty#';
                    continue;
                }
                if ($DEBUGCSS) print '#' . $selector . '#';
                //if ($DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }

                //FIXME: tag the selector with a hash of the media query to separate it from non-conditional styles (?), xpath comments are probably not what we want to do here
                if (count($media_queries) > 0) {
                    $style->set_media_queries($media_queries);
                }
                $this->add_style($selector, $style);
            }

            if ($DEBUGCSS) {
                print 'section]';
            }
        }

        if ($DEBUGCSS) {
            print '_parse_sections]';
        }
    }
410676
protected function generateSampleOutput($st_params, $counter)
    {
        if (!isset($st_params['ApiReturn'])) {
            $responseBody = '';
        } else {
          $ret = [];
          $partial_template = $this->loadPartialTemplate('sampleReponseTpl');
          foreach ($st_params['ApiReturn'] as $params) {
              if (in_array($params['type'], array('object', 'array(object) ', 'array', 'string', 'boolean', 'integer', 'number')) && isset($params['sample'])) {
                  $tr = array(
                      '{{ elt_id }}'      => $counter,
                      '{{ response }}'    => $params['sample'],
                      '{{ description }}' => '',
                  );
                  if (isset($params['description'])) {
                      $tr['{{ description }}'] = $params['description'];
                  }
                  $ret[] = strtr($partial_template, $tr);
              }
          }

          $responseBody = implode(PHP_EOL, $ret);
        }

        if(!isset($st_params['ApiReturnHeaders'])) {
          $responseHeaders = '';
        } else {
          $ret = [];
          $partial_template = $this->loadPartialTemplate('sampleReponseHeaderTpl');

          foreach ($st_params['ApiReturnHeaders'] as $headers) {
            if(isset($headers['sample'])) {
              $tr = array(
                '{{ elt_id }}'      => $counter,
                '{{ response }}'    => $headers['sample'],
                '{{ description }}' => ''
              );

              $ret[] = strtr($partial_template, $tr);
            }
          }

          $responseHeaders = implode(PHP_EOL, $ret);
        }

        return array($responseHeaders, $responseBody);
    }
274105
private function parseResponse($res) {
    $contents = explode("\n", $res);

    // Response comes back as HTTP/1.1 200 OK
    // Final line contains HTTP response.
    $status = explode(" ", $contents[0], 3);
    $result = $contents[count($contents) - 1];

    return array(
      "status"  => isset($status[1]) ? $status[1] : null,
      "message" => $result
    );
  }
536716
function parseResponse($data)
    {
        if (empty($data)) {
            return [];
        }

        if (isset($data[0]) && count($data[0]) === $this->getKeysCount()) {
            $items = array_combine($data[0], $data[1]);

            return array_filter($items, [$this, 'notNil']);
        }

        throw new Exception('Error when evaluate lua script. Response is: ' . json_encode($data));
    }
284270
public static function parseCommand($command)
    {
        if (preg_match('/([\w\\\\]+)::(\w+)\((.*)\)/', $command, $match)) {
            $params = explode(',', $match[3]);
            if ((1 == count($params)) && ('' == $params[0])) {
                //prevents to pass an empty string
                $params[0] = null;
            }
            return array(
                $match[1],
                $match[2],
                $params
            );
        }

        throw new TaskManagerException('Command not recognized');
    }
51419
private function parseYubicoResponse($response)
    {
        $lines = array_filter(explode("\r\n", $response));
        $responseArray = array();

        foreach ($lines as $line) {
            list($key, $value) = explode('=', $line, 2);

            $responseArray[$key] = $value;
        }

        return $responseArray;
    }
674026
public static function parseDisplayName($string, $data)
    {
        $response = array();

        if (isset($data->sn) && !empty($data->sn)) {
            $response['firstname'] = trim(str_replace($data->sn, "", substr($string, 0, strpos($string, " - "))));
            $response['lastname'] = $data->sn;
        } elseif (isset($data->mail) && strpos($data->mail, ".")) {
            $response['firstname'] = trim(substr($data->mail, 0, strpos($data->mail, ".")));
            $response['lastname'] = trim(substr($data->mail, strpos($data->mail, ".")+1, strpos($data->mail, "@")-strpos($data->mail, ".")-1));
        } else {
            $tempData = array();
            $tempData = trim(substr($string, 0, strpos($string, " - ")));

            if (!empty($tempData)) {

                $tempData = explode(" ", $tempData);

                if (is_array($tempData) && count($tempData)) {
                    $response['lastname'] = $tempData[0];
                    unset($tempData[0]);
                    $response['firstname'] = implode(" ", $tempData);
                }
            }
        }

        //Uppercase first letters
        $response['firstname'] = ucfirst($response['firstname']);
        $response['lastname'] = ucfirst($response['lastname']);

        return $response;
    }
606302
protected function parseUpdateStmt(){
		$values = array();
		list($table, $where) = $this->clauses;
		foreach($this->escapeValue($this->stmt->getValues()) as $col => $value){
			$values[] = $this->parseFieldName($col) . ' = ' . $value;
		}
		$data = "\nSET " . implode(', ', $values);
		return 'UPDATE ' . $table . $data . $where;
	}
329721
public function parseAll(array $data, int $fetchStyle, $fetchArgument = null, array $ctorArgs = array()): array
    {
        $result = [];
        foreach($data as $row)
        {
            switch($fetchStyle)
            {
                case \PDO::FETCH_COLUMN:
                    $item = $this->fetchParser->parseRow($row, \PDO::FETCH_BOTH);
                    $result[] = $item[$fetchArgument ?? 0] ?? null;
                    break;
                default:
                    $result[] = $this->fetchParser->parseRow($row, $fetchStyle);
                    break;
            }
        }
        return $result;
    }
254860
public function parseResponse($response)
    {
        $array = [];

        $exploded = explode('&', $response);

        foreach ($exploded as $explode) {
            $line = explode('=', $explode);

            if (isset($line[1])) {
                $array[$line[0]] = urldecode($line[1]);
            } else {
                $array[] = $explode;
            }
        }

        return $array;
    }
1372079
static public function resolveNginxStatus($str)
    {
        preg_match_all('/\d+/is', $str, $matched);
        if (count($matched[0]) === 7) {
            return [
                'connections' => (int)$matched[0][0],
                'accepts' => (int)$matched[0][1],
                'handled' => (int)$matched[0][2],
                'requests' => (int)$matched[0][3],
                'reading' => (int)$matched[0][4],
                'writing' => (int)$matched[0][5],
                'waiting' => (int)$matched[0][6]
            ];
        }

        return null;
    }
550025
private function parseLine($str, $color = null)
    {
        $parsed = [];
        $lines = explode(PHP_EOL, $str);
        $last = count($lines) - 1;
        foreach ($lines as $key => $line) {
            $parsed[] = [
                'colored' => $color ? sprintf("\033[%sm%s\033[0m", $color, $line) : $line,
                'original' => $line,
                'newline' => $key < $last
            ];
        }

        return $parsed;
    }