Hello...
I've got a problem on getting a variable content interpreted/inserted as php-code in one of my scripts.
For a class method i need two different ways of starting a loop while the content of these loops would be the same in both options. so i tried to put the header in a string, and evaluate it on execution, depending on whether a parameter was given or not. I tried to different methods of getting the command-string:with escaping the $'s, and without. But neither worked out. Here a code snippet of how i intend to use the above mentioned :
function create_tarray($inserttype="",$row="")
{
if ($row=="")
{
$checkcmd=eval("while($this->dbconnection->next_row()))";
//$checkcmd=eval("while(\$this->dbconnection->next_row()))";
}
else // in this case a two-dimensional array should have been given as parameter
{
$checkcmd=eval("foreach ($row as $array) ");
// $checkcmd=eval("foreach (\$row as \$array) "); // adjust checkcommand accordingly
}
eval($checkcmd); // this should be the loop-call
{
<...>
I would be happy about any suggestions on how i could get conditional-driven loop headers. Thank you in advance.