Tools, FAQ, Tutorials:
Passing Arrays to Function in PHP
Can You Pass an Array into a Function? in PHP?
✍: FYIcenter.com
You can pass an array into a function in the same as a normal variable. No special syntax needed. Here is a PHP script on how to pass an array to a function:
<?php function average($array) { $sum = array_sum($array); $count = count($array); return $sum/$count; } $numbers = array(5, 7, 6, 2, 1, 3, 4, 2); print("Average: ".average($numbers)."\n"); ?>
This script will print:
Average: 3.75
⇒ Passing Arrays by Values to Functions in PHP
⇐ Defining an Argument as a Reference in PHP
2023-04-06, 2113🔥, 1💬
Popular Posts:
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...
How to use .NET CLR Types in Azure API Policy? By default, Azure imports many basic .NET CLR (Common...
Where Is the Submitted Form Data Stored in PHP? When a user submit a form on your Web server, user e...
What Is HTML? HTML (HyperText Markup Language) is the standard markup language for creating Web page...
How To Read the Entire File into a Single String in PHP? If you have a file, and you want to read th...