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
Â
⇒Creating Your Own Functions in PHP
⇒⇒PHP Tutorials
2016-12-18, 1309👍, 0💬
Popular Posts:
How to create a navigation file like navigation.xhtml for an EPUB 3.0 book? At least one navigation ...
How to create Hello-2.0.epub with WinRAR? I have all required files to create Hello-2.0.epub. To cre...
How to include additional claims in Azure AD v2.0 id_tokens? If you want to include additional claim...
What is Azure API Management Publisher Portal 2017 version? Azure API Management Publisher Portal is...
What is the "__init__()" class method? The "__init__()" class method is a special method that will b...