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, 2118🔥, 1💬
Popular Posts:
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...
How to pull NVIDIA CUDA Docker Image with the "docker image pull nvidia/cuda" command? If you are ru...
How To Open Standard Output as a File Handle in PHP? If you want to open the standard output as a fi...
How to use the XML to JSON Conversion Tool at freeformatter.com? If you want to try the XML to JSON ...
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...