Hi,
I have a "loop" that should pass varying arguments to variable functions. These functions have varying number of arguments that each one of them can accept.
My problem is how am I going to pass the right number of arguments to the varying functions that I have in my loop.
func_num_args() can only be called once you're already inside the function.
Is there a function in PHP that can determine the number of arguments a certain function accepts before calling that certain function?
here's a quick view of my snippet:
// table: data
$blnGoArray = is_array($arrFuncs);
$strCurrShade = $this->strRowAltColour2;
while($row = mysql_fetch_row($result)) {
if ($blnGoArray) reset($arrFuncs);
$strCurrShade = ($strCurrShade == $this->strRowAltColour1) ? $this->strRowAltColour2 : $this->strRowAltColour1;
$strDisplay .= "\t<tr>$strEol";
foreach($row as $val) {
$strDisplay .= "\t\t<td bgcolor=\"$strCurrShade\" align=\"CENTER\" valign=\"MIDDLE\">$strEol";
if ($blnGoArray) {
$currFunc = current($arrFuncs);
next($arrFuncs);
if (function_exists($currFunc)) {
$strDisplay .= "\t\t\t" . $this->setText($currFunc($val, $row)) . "$strEol";
} else {
$strDisplay .= "\t\t\t" . $this->setText($val) . "$strEol";
}
} else {
$strDisplay .= "\t\t\t" . $this->setText($val) . "$strEol";
}
$strDisplay .= "\t\t</td>$strEol";
}
$strDisplay .= "\t</tr>$strEol";
}
$arrfuncs is an array of string function names.
$strEol is just escape characters for end of line.
$_strRowAltColour's are just colour strings for the alternating HTML table row colours.
$this->setText() is just a function that formats your string into a HTML-Font-formatted text.
the code above works fine, it just doesn't seem right. it's messy to assume that all functions accept more than one arguments.
i need suggestions.
TYIA,
Nil