Hello there,
We are using this function bellow to return the output of functions that normally echo this output.
Example:
function print_A($cant)
{
for ($i=0;$i<$cant;$i++)
echo "A";
}
$a = devolver("print_A",3);
As you can see, devolver takes as parameters:
The name of the function, and all its corresponding parameters.
This is working great when none of the parameters required is an array.
Ejample:
$a= array(1,2,3,4);
$b = devolver("some_function",$a,3);
The problem is that the function devolver doesn´t explodes the array.
$llamada gets:
some_function(ARRAY,3);
Which of course doesn´t work.
If anyone comes up with an idea it will be very appreciated.
Regards
Guillermo
function devolver ($funcion)
{
$llamada = $funcion ."(";
$parametros = func_get_args ();
for ($i = 1; $i < count ($parametros); $i++)
{
if ($i != 1)
$llamada .= ",";
$llamada .= $parametros[$i];
}
$llamada .= ");";
ob_start ();
eval ($llamada);
$s = ob_get_contents ();
ob_end_clean ();
return $s;
}