Formats string by replacing ":variable:" with given values

@param string  $str   Input string
@param array   $args  Variables to be replaced

@return string
16574
public static function formatString($str, $args)
    {
        foreach ($args as $k => $v) {
            $str = preg_replace('/:'. $k. ':/', $v, $str);
        }
        return $str;
    }
619986
static public function interpolate($str, array $vars) {
        $keys = array_keys($vars);
        $vals = array_values($vars);
        // surround keys by "%"
        array_walk(
            $keys, function (&$s) {
                $s = '%' . $s . '%';
            }
        );
        $str = str_replace($keys, $vals, $str);
        return $str;
    }
552218
public static function quote($str)
    {
        static $flags;

        if (!$flags) {
            $flags = ENT_COMPAT;
            if (defined('ENT_SUBSTITUTE')) {
                $flags |= ENT_SUBSTITUTE;
            }
        }

        return @htmlspecialchars($str, $flags, RCUBE_CHARSET);
    }
658420
public static function trad2simp($str) {
    if (empty($str)) {
      throw new Exception('Argument str cannot be empty');
    }
    $ords = self::utf8ToUnicode($str);
    foreach ($ords as $k => $val) {
      if ($val !== false && array_key_exists($val, self::$trad2simple)) {
        $ords[$k] = self::$trad2simple[$val];
      }
      else {
        $ords[$k] = $val;
      }
    }
    return self::unicodeToUtf8($ords);
  }
284133
public static function replace(string $str, array $values): string
    {
        return str_replace(array_keys($values), array_values($values), $str);
    }
467593
public static function replaceRoman(string $str) : string
    {
        $str = self::strToArray($str);
        return implode('', self::replaceRomanArray($str));
    }
1371299
public static function format($str)
    {
        preg_match('/<[A-Za-z0-9]+?>/', $str, $matches);

        foreach ($matches as $match) {
            $keyword = str_replace(array('<', '>'), '', $match);

            $format = static::$collection->get(strtolower($keyword));

            if (!empty($format)) {
                $foreground = (!isset($format['foreground']) ? '' : "\33[".$format['foreground']."m");
                $background = (!isset($format['background']) ? '' : "\33[".$format['background']."m");

                $str = str_replace(
                    array('<'.$keyword.'>', '</'.$keyword.'>'),
                    array($foreground.$background, "\33[0m"),
                    $str
                );
            }
        }

        return $str;
    }
1338364
private function generateAppletTag($str) {
	$this->logDebug('generateAppletTag', 'Entering function');
	$str = preg_replace('/'.$this->classparams['tag_jscript'].'/', $this->str_jsinit(), $str);
	return preg_replace('/'.$this->classparams['tag_applet'].'/', $this->str_applet(), $str);
}
219264
protected function translate($str, $params = array())
    {
        if (isset($this->translator)) {
            return $this->translator->trans($str, $params);
        }
        else {
            $finalParams = array();
            foreach ($params as $placeholder => $value) {
                $finalParams['{'.$placeholder.'}'] = $value;
            }
            return strtr($str, $finalParams);
        }
    }
1199219
public static function prepareCommand(array $args)
    {
        $return = '*' . \count($args) . "\r\n";
        foreach ($args as $arg) {
            $return .= '$' . \strlen($arg) . "\r\n" . $arg . "\r\n";
        }

        return $return;
    }
666564
private function Format($args){
		$message = array();
		if( $args ){
			foreach($args as $a){
				$argValue = '';
				if( $a['name'] ){
					$argValue .= $a['name'] . ':';
				}
				if( is_object($a['value']) ){
					$argValue .= $a['value']->toCSS();
				}else{
					$argValue .= '???';
				}
				$message[] = $argValue;
			}
		}
		return implode(', ',$message);
	}
1227176
protected function _formatNewlines($str) {
		if ($str === '') {
			return $str;
		}

		if (strpos($str, "\n") === false && !in_array($this->lastBlockElement, $this->innerBlockRequired)) {
			return $str;
		}

		// Convert two consecutive newlines to paragraphs
		$str = str_replace("\n\n", "</p>\n\n<p>", $str);

		// Convert single spaces to <br /> tags
		$str = preg_replace("/([^\n])(\n)([^\n])/", '\\1<br />\\2\\3', $str);

		// Wrap the whole enchilada in enclosing paragraphs
		if ($str !== "\n") {
			// We trim off the right-side new line so that the closing </p> tag
			// will be positioned immediately following the string, matching
			// the behavior of the opening <p> tag
			$str = '<p>' . rtrim($str) . '</p>';
		}

		// Remove empty paragraphs if they are on the first line, as this
		// is a potential unintended consequence of the previous code
		$str = preg_replace("/<p><\/p>(.*)/", '\\1', $str, 1);

		return $str;
	}
487650
public function formatArgs($args)
    {
        $result = [];
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $parts = explode('\\', $item[1]);
                $short = array_pop($parts);
                $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } elseif ('null' === $item[0]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), ENT_COMPAT | ENT_SUBSTITUTE, $this->charset));
            }

            $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
        }

        return implode(', ', $result);
    }
962946
public static function strFindAndReplaceAll($vars = array(), $str)
    {
        if (array_count_values($vars) > 0){
            foreach ($vars as $key => $val) {
                for ($i = substr_count($str, $key); $i > 0; $i--) {
                    $str = \WebCMS\Helpers\SystemHelper::strlReplace($key, $val, $str);
                }
            }
        }
        return $str;
    }
818818
public static function constructFromString($str) {
		$str = strtoupper($str);
		$i = substr($str, -1) == 'I';

		preg_match('/^T[0-9]{1,}/', $str, $matches);
//		print_r($matches);
		$r = $matches[0];

		return new PitchClassSetTransformation($r, $i);
	}
83338
public static <T> String argsToString(String separator, T... args) {
    StringBuilder sb = new StringBuilder();
    for (T s : args) {
      if (sb.length() != 0) {
        sb.append(separator);
      }
      sb.append(s);
    }
    return sb.toString();
  }
888440
protected function format($str, $indent = true)
    {
        $spaces = str_repeat(' ', ((int)$indent) * $this->indent);

        return $spaces . trim(
            str_replace(
                "\n",
                "\n" . $spaces,
                (php_sapi_name() != 'cli' ? htmlspecialchars($str) : $str)
            )
        ) . "\n";
    }