Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Plus #148

Open
GeneticsPro opened this issue Feb 1, 2021 · 0 comments
Open

Filter Plus #148

GeneticsPro opened this issue Feb 1, 2021 · 0 comments

Comments

@GeneticsPro
Copy link

Hello. I propose to improve the "plus" function.

public static function plus($input, $operand)

For the possibility of adding an unlimited number of parameters.
Example:
{{ 4 | plus: 2, 3, 7 }}

Решение:

public static function plus($input, $operand)
{
	//return (float)$input + (float)$operand;

	$args = func_get_args();
	unset($args[0]);

	if ($args)
	{
		$input = (float) $input;

		foreach ($args as $arg)
		{
			if ($arg)
			{
				$input += (float) $arg;
			}
		}

		return $input;
	}
	else
	{
		return $input;
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants