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, ∼2749🔥, 1💬
Popular Posts:
How to register and get an application ID from Azure AD? The first step to use Azure AD is to regist...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...
dev.FYIcenter.com is a Website for software developer looking for software development technologies,...
What is Azure API Management Developer Portal? Azure API Management Developer Portal is an Azure Web...
How to use the "set-variable" Policy Statement to create custom variables for an Azure API service o...