src/Suki/Tools.php
public function parser($text, $replacements = []): string
	{
		global $context;

		if (empty($text) || empty($replacements) || !is_array($replacements))
			return '';

		// Split the replacements up into two arrays, for use with str_replace.
		$find = [];
		$replace = [];

		foreach ($replacements as $f => $r)
		{
			$find[] = '{' . $f . '}';
			$replace[] = $r . ((strpos($f,'href') !== false) ? (';'. $context['session_var'] .'='. $context['session_id']) : '');
		}

		// Do the variable replacements.
		return str_replace($find, $replace, $text);
	}
public function parser($text, $replacements = []): string
	{
		global $context;

		if (empty($text) || empty($replacements) || !is_array($replacements))
			return '';

		// Split the replacements up into two arrays, for use with str_replace.
		$find = [];
		$replace = [];

		foreach ($replacements as $f => $r)
		{
			$find[] = '{' . $f . '}';
			$replace[] = $r . ((strpos($f,'href') !== false) ? (';'. $context['session_var'] .'='. $context['session_id']) : '');
		}

		// Do the variable replacements.
		return str_replace($find, $replace, $text);
	}
public function parser ( $ text , $ replacements = [ ] ) : string { global $ context ; if ( empty ( $ text ) || empty ( $ replacements ) || ! is_array ( $ replacements ) ) return '' ; // Split the replacements up into two arrays, for use with str_replace. $ find = [ ] ; $ replace = [ ] ; foreach ( $ replacements as $ f => $ r ) { $ find [ ] = '{' . $ f . '}' ; $ replace [ ] = $ r . ( ( strpos ( $ f , 'href' ) !== false ) ? ( ';' . $ context [ 'session_var' ] . '=' . $ context [ 'session_id' ] ) : '' ) ; } // Do the variable replacements. return str_replace ( $ find , $ replace , $ text ) ; }
Parses and replace tokens by their given values.
also automatically adds the session var for href tokens.
@access public
@param string $text The raw text.
@param array $replacements a key => value array containing all tokens to be replaced.
@return string
Parses and replace tokens by their given values . also automatically adds the session var for href tokens .