From ed4ac31d97b36866a48faf3b9328c320ba55074f Mon Sep 17 00:00:00 2001 From: Sawyer Charles Date: Sun, 18 Oct 2015 17:46:23 -0500 Subject: Added variable amount of parameters as of php 5.6+ --- php.html.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/php.html.markdown b/php.html.markdown index 5bc2ddce..e7b57b4b 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -445,6 +445,16 @@ function parameters() { parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World | +// Since PHP 5.6 you can get a variable number of arguments +function variable($word, ...$list) { + echo $word . " || "; + foreach ($list as $item) { + echo $item . ' | '; + } +} + +variable("Separate", "Hello", "World") // Separate || Hello | world | + /******************************** * Includes */ -- cgit v1.2.3 From b4c8ff365ee1d633470ced72de5f540744fa921a Mon Sep 17 00:00:00 2001 From: Sawyer Charles Date: Sun, 18 Oct 2015 17:47:42 -0500 Subject: capital letter --- php.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php.html.markdown b/php.html.markdown index e7b57b4b..71f23871 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -453,7 +453,7 @@ function variable($word, ...$list) { } } -variable("Separate", "Hello", "World") // Separate || Hello | world | +variable("Separate", "Hello", "World") // Separate || Hello | World | /******************************** * Includes -- cgit v1.2.3