eval problem
Posted: Thu Aug 10, 2006 10:50 am
Hi,
The following code intends to cycle through a two dimensional representation of a database recordset and create an array for every column with the array name being the name of the column...
this gives me the error: Parse error: parse error, unexpected T_STRING in .... : eval()'d code on line 1
this code however works:
am I missing something? Do you need more information to answer my question?
The following code intends to cycle through a two dimensional representation of a database recordset and create an array for every column with the array name being the name of the column...
Code: Select all
foreach ($this->results as $row_n => $row) {
foreach ($row as $column => $value) {
$evalcode = '$this->' . strtolower($column) . "[$row_n]" . " = '$value';";
eval($evalcode);
}
}this code however works:
Code: Select all
$column = "hello";
$row_n = "3";
$value = "t";
$evalcode = '$this->' . strtolower($column) . "[$row_n]" . " = '$value';";
eval($evalcode);