Categories:
.NET (357)
C (330)
C++ (184)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Define a Function with Any Number of Arguments
How To Define a Function with Any Number of Arguments? - PHP Script Tips - Creating Your Own Functions
✍: FYIcenter.com
If you want to define a function with any number of arguments, you need to:
Here is a PHP script on how to handle any number of arguments:
<?php
function myAverage() {
$count = func_num_args();
$args = func_get_args();
$sum = array_sum($args);
return $sum/$count;
}
$average = myAverage(102, 121, 105);
print("Average 1: $average\n");
$average = myAverage(102, 121, 105, 99, 101, 110, 116, 101, 114);
print("Average 2: $average\n");
?>
This script will print:
Average 1: 109.33333333333 Average 2: 107.66666666667
2007-04-25, 4973👍, 0💬
Popular Posts:
How does multi-threading take place on a computer with a single CPU? The operating system's task sch...
What is COCOMO I, COCOMOII and COCOMOIII? In CD we have a complete free PDF tutorial of how to prepa...
In C#, what is a weak reference? Generally, when you talk about a reference to an object in .NET (an...
How To Use Subqueries in the FROM clause? - MySQL FAQs - SQL SELECT Statements with JOIN and Subquer...
How do you locate the first X in a string txt? A) txt.find('X'); B) txt.locate('X'); C) txt.indexOf(...