How to get a set of variables returned by a function using an arrayFrom a function we can get back a set of variables by using an array. A function returns any variable to the main script by using return statement. Here we will try to return a set of variables by using an array. Our main script will receive the array and we will use while each statement to display all elements of an array.
We will change a script a bit and try to pass ( as input ) a string to the function. This string we will break by using split command and create an array. This array we will return to main script for displaying.
Here is the code ..
Passing an array as input to PHP functionAbove we have discussed how to return an array from a function. Now we will discuss how to input or pass an array to a function.
We will break an string and create an array. This created array we will pass as input to the function. To test the array inside the function we will display it by using while each command.
Here is the code.
This article is written by plus2net.com team.