i was wondering if there is a "String...stringArray" equivalent in PHP, something that can build an array based on "stringArray" parameters, i.e.
Java:
public void method1(){
int aNumber = 4;
String string1 = "first string";
String string2 = "second string";
String string3 = "third string";
processStrings(aNumber, string1, string2, string3);
/*
string1, string2 and string3 will become b = {string1, string2, string3}
in function "processStrings"
*/
}
public void processStrings(int a, String...b){
System.out.println(b[0]); //in this case it will print out "first string"
System.out.println(b[1]); //in this case it will print out "second string"
System.out.println(b[2]); //in this case it will print out "third string"
}
Is there a way to do the same thing with PHP?
I know i can use
function processStrings($a, $b){}
and then call it like this
function method1(){
$myInt = 4;
$strings = array("first string","second string","third string");
processStrings($myInt, $strings);
}
But i would like to know if there is a way to pass an undefined number of parameters like i do with Java