fileserverdirect
09-20-2010, 09:57 PM
Yes I googled this, but I could not find anything. Here is my function that is in a class:
public function create()
{
$args = func_get_args();
$element = $args[0];
if(isset($this->elements->$element)) {
$value=$this->elements->$element;
unset($args[0]);
$format = implode(", ", $args);
printf($value, $format);
return true;
}
else {
return false;
}
}
My problem is that I want to replace each argument from the original create() function into printf. $this->elements contains an object with formatted elements, ready for printf. I have gotten this to work with one argument, but some elements require multiple ones. How do I pass an array into arguments that a function will read each as it's own argument?
public function create()
{
$args = func_get_args();
$element = $args[0];
if(isset($this->elements->$element)) {
$value=$this->elements->$element;
unset($args[0]);
$format = implode(", ", $args);
printf($value, $format);
return true;
}
else {
return false;
}
}
My problem is that I want to replace each argument from the original create() function into printf. $this->elements contains an object with formatted elements, ready for printf. I have gotten this to work with one argument, but some elements require multiple ones. How do I pass an array into arguments that a function will read each as it's own argument?