I am trying to create a PHP function with 2 parameters. One parameter is a variable and the second is an array like this
<?php
function Myfunction($variable, $array=array()){
foreach($array as $item){
echo $variable;
echo $item;
}
}
?>
I want a call like this:
<?php
Myfunction(blue, 1,3,6,10,5);
?>
"blue" is the variable "numbers" insert in an array.
I tried something but it does not work.
Who can help me with this?
Myfunction('blue', array(1,3,6,10,5));will help.MyFunction(blue, [1,3,6,10,5]);