mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Added variable amount of parameters as of php 5.6+
This commit is contained in:
parent
ba5f3ebc11
commit
ed4ac31d97
@ -445,6 +445,16 @@ function parameters() {
|
|||||||
|
|
||||||
parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World |
|
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
|
* Includes
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user