SQL PHP HTML ASP JavaScript articles and free scripts to download
 

How to pass an array as input to an php function

In part I we have discussed how to return an array from a function. Here 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.


function test($my_array){
while (list ($key, $val) = each ($my_array)) {
echo "$key -> $val <br>";
}

}

$collect_array=split(" ","Hello welcome to plus2net"); test($collect_array);


<< In the part I we discussed on how to return array from an php function.

Discuss this tutorial at forum


Further readings
PHP Function
Declaring variables as global inside the function
Returning variable from a function
Returning an array from a function to main script
Array as input to a function








 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Functions
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
PHP Introduction
Loops & structure
Array
Date & Time
Functions
Form Handling
File Handling
Math Functions
String Functions
GD Functions
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.