diff options
Diffstat (limited to 'stupid_template_engine.php')
| -rw-r--r-- | stupid_template_engine.php | 38 | 
1 files changed, 38 insertions, 0 deletions
| diff --git a/stupid_template_engine.php b/stupid_template_engine.php index 6acb6d7..e8e78ec 100644 --- a/stupid_template_engine.php +++ b/stupid_template_engine.php @@ -1396,6 +1396,44 @@ class STEStandardLibrary  	{  		return @strftime($sub($ste), empty($params["timestamp"]) ? @time() : (int) $params["timestamp"]);  	} +	 +	static public function in_array($ste, $params, $sub) +	{ +		if(empty($params["array"])) +			throw new RuntimeError("Missing array parameter in <ste:in_array>."); +		$ar = &$ste->get_var_reference($params["array"], False); +		if(!is_array($ar)) +			return ""; +		return in_array($sub($ste), $ar) ? "y" : ""; +	} +	 +	static public function join($ste, $params, $sub) +	{ +		if(empty($params["array"])) +			throw new RuntimeError("Missing array parameter in <ste:join>."); +		return implode($sub($ste), $ste->get_var_by_name($params["array"])); +	} +	 +	static public function split($ste, $params, $sub) +	{ +		if(empty($params["array"])) +			throw new RuntimeError("Missing array parameter in <ste:split>."); +		if(empty($params["delim"])) +			throw new RuntimeError("Missing delim parameter in <ste:split>."); +		$ste->set_var_by_name($params["array"], explode($params["delim"], $sub($ste))); +	} +	 +	static public function array_add($ste, $params, $sub) +	{ +		if(empty($params["array"])) +			throw new RuntimeError("Missing array parameter in <ste:array_add>."); +		 +		$ar = &$ste->get_var_reference($params["array"], True); +		if(empty($params["key"])) +			$ar[] = $sub($ste); +		else +			$ar[$params["key"]] = $sub($ste); +	}  }  ?>
\ No newline at end of file | 
