Similar to parse_str()

Returns an associative array of name/value pairs, where the value is an
array of values that have used the same name

@static
@param string $str The input string.
@return array
771351
public static function parse_str($str)
	{
		$return = array();
		$str = explode('&', $str);

		foreach ($str as $section)
		{
			if (strpos($section, '=') !== false)
			{
				list($name, $value) = explode('=', $section, 2);
				$return[urldecode($name)][] = urldecode($value);
			}
			else
			{
				$return[urldecode($section)][] = null;
			}
		}

		return $return;
	}
232552
public function parse($str): array
    {
        $definition = [];

        if (empty($str)) {
            // Return empty definition
            return $definition;
        }

        // Directives are delimited with a pipe operator
        foreach (preg_split('/\s*\|\s*/', $str) as $directive) {
            // May consist of "directive:value" or it may just be "directive".
            $parts = explode(':', $directive, 2);
            $key = $parts[0];
            $value = $parts[1] ?? null;

            if (isset($this->shortKeys[$key])) {
                if ($value !== null) {
                    // If a value was also provided, we'll store that in a separate entry.
                    $definition[$this->normalizeKey($key)] = $value;
                }
                $value = $key;
                $key = $this->shortKeys[$key];
            }

            if (!$this->isAllowedKey($key)) {
                throw new ParseDefinitionException("Unsupported key '$key'");
            }

            // Normalise our directive (as snake_case) and store the value.
            $definition[$this->normalizeKey($key)] = $value;
        }

        return $definition;
    }
481757
public static function replaceRomanArray(array $str) : array
    {
        foreach ($str as $key => $value) {
            $code = Mbstring::mb_ord($value);
            if ($code >= 8544 && $code <= 8555) {
                $str[$key] = self::toRoman($code - 8543);
            } elseif ($code >= 8560 && $code <= 8571) {
                $str[$key] = self::toSmallRoman($code - 8559);
            } else {
                switch ($code) {
                    case 8556:
                        $str[$key] = self::toRoman(50);
                        break;
                    case 8557:
                        $str[$key] = self::toRoman(100);
                        break;
                    case 8558:
                        $str[$key] = self::toRoman(500);
                        break;
                    case 8559:
                        $str[$key] = self::toRoman(1000);
                        break;
                    case 8572:
                        $str[$key] = self::toSmallRoman(50);
                        break;
                    case 8573:
                        $str[$key] = self::toSmallRoman(100);
                        break;
                    case 8574:
                        $str[$key] = self::toSmallRoman(500);
                        break;
                    case 8575:
                        $str[$key] = self::toSmallRoman(1000);
                        break;
                    default:
                        break;
                }
            }
        }
        return $str;
    }
1340350
public static function fromString($str)
    {
        $stringset = new Stringset();

        $entry = array();
        $state = null;
        $line = 1;

        foreach (explode("\n", $str) as $line) {
            $line = trim($line);
            if (strlen($line) === 0) {
                if (count($entry) > 0) {
                    $stringset->add($entry);
                    $entry = array();
                    $state = null;
                }
                continue;
            }

            if ($line[0] === '#' && $line[1] === ',') {
                $entry['flags'] = array_map('trim', explode(',', substr($line, 2)));
            } else if ($line[0] !== '#') {
                // non-comment
                list($key, $rest) = explode(' ', $line, 2);
                switch ($key) {
                    case 'msgid':
                    case 'msgid_plural':
                    case 'msgstr':
                    case 'msgctxt':
                        if (strpos($state, 'msgstr') === 0 && $key !== 'msgstr' && count($entry) > 0) {
                            $stringset->add($entry);
                            $entry = array();
                        }
                        $state = $key;
                        $entry[$key] = self::parseString($rest);
                        break;
                    default:
                        if (strpos($key, 'msgstr[') === 0) {
                            $state = $key;
                            $entry[$key] = self::parseString($rest);
                        } else {
                            $entry[$state] .= self::parseString(trim($line));
                        }
                }
            }
            $line += 1;
        }
        return $stringset;
    }
635070
public static function decode(String $str) : String
    {
        return preg_replace
        (
            array_keys(self::$scriptTagCharsDecode), 
            array_values(self::$scriptTagCharsDecode), 
            $str
        );
    }
628912
public static function lines(string $str): array
    {
        $lines = BaseStringy::create($str)->lines();

        foreach ($lines as $i => $line) {
            $lines[$i] = $line;
        }

        /** @var string[] $lines */
        return $lines;
    }
548866
protected function parseAnnotations($str)
    {
        $annotations = [];
        preg_match_all($this->dataPattern, $str, $found);
        foreach ($found[2] as $key => $value) {
            $annotations[ $this->sanitizeKey($found[1][$key]) ][] = $this->parseValue($value, $found[1][$key]);
        }

        return $annotations;
    }
1348183
public function decode($str) {

		$str = strtoupper($str);

		$l = strlen($str);
		$n = 0;
		$b = 0;

		$decoded = null;

		for ($i = 0; $i < $l; $i++) {
			$n = $n << 5;
			$n = $n + $this->decodeTable[$str[$i]];
			$b = $b + 5;

			if ($b >= 8) {
				$b = $b - 8;
				$decoded .= chr(($n & (0xFF << $b)) >> $b);
			}
		}

		return $decoded;
	}
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;
    }
1337647
public static function str2array($str, $sep = ',')
    {
        $str = trim($str, "$sep ");

        if (!$str) {
            return [];
        }

        return preg_split("/\s*$sep\s*/", $str, -1, PREG_SPLIT_NO_EMPTY);
    }
461908
private function processAttributes($str)
	{
		static $pattern='/(\w+)\s*=\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)"|\{.*?\})/msS';
		$attributes=array();
		$n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER);
		for($i=0;$i<$n;++$i)
		{
			$match=&$matches[$i];
			$name=$match[1];
			$value=$match[2];
			if($value[0]==='{')
				$attributes[]="'$name'=>".str_replace('__FILE__',$this->_sourceFile,substr($value,1,-1));
			else
				$attributes[]="'$name'=>$value";
		}
		return implode(', ',$attributes);
	}
983461
public final function parse($param_str) {
        $params = explode(",", $param_str);
        foreach ($params as $param_item) {
            $param_kv = explode("=", $param_item);
            $param_key = trim($param_kv[0]);
            $param_value = trim($param_kv[1]);
            if ('"' === substr($param_key, 0, 1) && '"' === substr($param_key, -1, 1)) {
                $param_key = substr($param_key, 1, strlen($param_key) - 2);
            }
            if ('"' === substr($param_value, 0, 1) && '"' === substr($param_value, -1, 1)) {
                // This param_value is a string type, which could be set directly
                if (property_exists($this, $param_key)) {
                    $this->$param_key = substr($param_value, 1, strlen($param_value) - 2);
                } else {
                    // @TODO support special variables like from `@use`
                }
            }
        }
    }
526492
private function parseHeaders($str) {

		if(false === is_string($str)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($str)), E_USER_ERROR);
		}
		
		$headers = [];
		$status  = [];

		foreach(explode("\n", $str) as $header) {
			
			if(preg_match('/(:)/is', $header)) {
				list($key, $value) = preg_split('/(:)/is', $header, 2);
			}
			else {
				$key = $header;
			}

			if(trim($key) !== '') {

				if(preg_match('/(https?\/[0-9]\.[0-9])/i', $key, $http)) {

					$status['code'] = null;

					if(preg_match('/([0-9]+)/', ltrim($key, $http[0]), $code)) {
						$status['code'] = $code[0];
					}

					$status['protocol'] = $http[0];
					$status['status'] 	= trim($key);
					$status['text'] 	= trim(ltrim(trim(ltrim($key, $status['protocol'])), $status['code']));
					
				}
				else {
					$headers[strtolower($key)] = trim($value);
				}
			}
		}

		return ['headers' => $headers, 'status' => $status];
	}
301766
private function parse($str)
    {
        $str = trim($str);
        $this->expression = $str;
        $strlen = strlen($str);
        $main_array = [];
        $count = 0;

        for ($i=0; $i<$strlen; $i++) {

            $str_i = $str[$i];
            $str_ip1 = (isset($str[$i+1])) ? $str[$i+1] : null;
            $str_ip2 = (isset($str[$i+2])) ? $str[$i+2] : null;
            $str_ip3 = (isset($str[$i+3])) ? $str[$i+3] : null;
            $str_ip4 = (isset($str[$i+4])) ? $str[$i+4] : null;
            $str_im1 = (isset($str[$i-1])) ? $str[$i-1] : null;
            $str_im2 = (isset($str[$i-2])) ? $str[$i-2] : null;

            // NaN
            if (stristr($str, 'NaN'))
                return NAN;
            // Spaces will be skipped
            if ($str_i == ' ') {
                $count++;
            // Number
            } elseif (is_numeric($str_i)) {
                $main_array[$count] = (isset($main_array[$count])) ?
                        $main_array[$count].$str_i : $str_i;
            // Constant pi
            } elseif ($str_im1.$str_i == 'pi') {
            } elseif (($str_i.$str_ip1 == 'pi')
            && (!$str_ip2 || strstr('+-*/^ ', $str_ip2))) {
                $count++;
                $main_array[$count] = M_PI;
            // Constant e
            } elseif (($str_i == 'e') && ($str_ip1 != 'x') && (!is_numeric($str_im1))
            && (!$str_ip1 || strstr('+-*/^ ', $str_ip1))) {
                $count++;
                $main_array[$count] = M_E;
            // Number in E notation
            } elseif ((strtolower($str_i) == 'e') && ($str_ip1 != 'x')
            && (is_numeric($str_im1))) {
                $main_array[$count] = $main_array[$count].'E';
            } elseif ((strstr('+-', $str_i)) && (strtolower($str_im1) == 'e')
            && (is_numeric($str_ip1)) && (is_numeric($str_im2))) {
                $main_array[$count] = $main_array[$count].$str_i;
            // Decimal point
            } elseif (($str_i == '.') && ((isset($str_im1) && is_numeric($str_im1)) 
            || (isset($str_ip1)) && is_numeric($str_ip1))) {
                $main_array[$count] = (isset($main_array[$count])) ? 
                        $main_array[$count].'.' : '.';
            // Function
            } elseif ((in_array($str_i.$str_ip1.$str_ip2, $this->valid_functions))
            || ($str_i.$str_ip1.$str_ip2.$str_ip3 == 'sqrt')) {
                if ($str_i.$str_ip1.$str_ip2.$str_ip3 == 'sqrt') {
                    if ($str_ip4 == ' ')
                        $this->calculateFunction('sqrt', $str, $strlen, $i);
                } else {
                    if ($str_ip3 == ' ')
                        $this->calculateFunction($str_i.$str_ip1.$str_ip2, $str, $strlen, $i);
                }
            // Variable
            } elseif (in_array($str_i, $this->valid_variables) && count($this->variables)) {
                if (array_key_exists($str_i, $this->variables)
                && is_numeric($this->variables[$str_i])) {
                    $main_array[$count] = (float) $this->variables[$str_i];
                    $count++;
                } else {
                    $this->correct = 0;
                    $this->error_type = 4;
                    break;
                }
            } else {
                // Operator
                $count++;
                if (strstr('+-*/^', $str_i)) {
                    if (!count($main_array) && $str_i == '+')
                        continue;
                    $main_array[$count] = $str_i;
                    $count++;
                } else {
                    // Constant Inf
                    if ($str_im2.$str_im1.$str_i == 'INF') {
                    } elseif ($str_im1.$str_i.$str_ip1 == 'INF') {
                    } elseif ($str_i.$str_ip1.$str_ip2 == 'INF') {
                        if ($str_im1 == '-' && !count($main_array)) {
                            $main_array[$count] = '-';
                            $count++;
                        }
                        $main_array[$count] = INF;
                        $count++;
                    } else {
                        // Nothing matches
                        $this->correct = 0;
                        if (!$this->validate())
                            $this->error_type = 1;
                        break;
                    }
                }
            }
        }

        if (!$this->correct)
            return 0;

        $main_array = array_values($main_array);

        if (isset($main_array[1])) {

            $main_array = $this->combine($main_array);
            $main_array = $this->calculate1($main_array);
            $main_array = $this->calculate2($main_array);
            $main_array = $this->calculate3($main_array);

            if (count($main_array) != 1)
                $this->correct = 0;
        }

        if (!isset($main_array[0]) || strstr('+-*/^', (string) $main_array[0])
        || substr_count((string) $main_array[0], '.') > 1) {
            $this->correct = 0;
            return 0;
        }

        return $this->return_($main_array[0]);
    }
816789
public function parseString($str) {
        if (!extension_loaded("SimpleXML"))
            throw new XmlParserException("SimpleXML extension not loaded, can not parse XML");
        
        libxml_use_internal_errors(true);
        $xml = simplexml_load_string($str);
        
        if ($xml === false) {
            $msg = "The following XML errors occurred while parsing:";
            foreach (libxml_get_errors() as $error)
                $msg .= "\n" . $error->message;
            throw new XmlParserException($msg);
        }

        $this->xml = $xml;
        $this->xmlString = $str;
        return $this;
    }
170971
public static function get(string $str):array
    {
        $str = trim($str);
        $strArr = Str::toArray($str);
        $results = [];
        foreach ($strArr as $s) {
            $results[] = self::getSingle($s);
        }
        return $results;
    }
169592
protected static function parseAs($str, $alias1 = null) {
        $table = preg_split('#\b(as|\s+)\b#i', trim($str));
        if (count($table) == 1) {
            $name  = $table [0];
            $alias = $alias1;
        } else {
            $name  = $table [0];
            $alias = trim(array_pop($table));
        }

        return [trim($name), trim($alias)];
    }