mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-26 09:21:00 +03:00
Merge pull request #1638 from xssc/patch-1
[php/en] Added variable amount of parameters as of php 5.6+
This commit is contained in:
commit
329166d986
@ -452,6 +452,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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user