Date: 10/01/2005 09:20
Hi All
I need to dynamically generate some variables that need to be sent to a function, I have an example of what I am trying to do. The problem is, the stuff I am sending to the function is an array of variables (e.g. array($var1,$var2)). I actually really need to send them as the actual variables.
I tried to use the get_defined_vars() and the extract functions, but to no avail.
Here is the code (sample not run through parser, merely for conceptual purpose):
Code: Select all
<?php
$insert_table = "my_table";
$fields = $ADO-> getParameters($insert_table); // Get Fields for Table
// Extra Fields passed as parameters
$parameters = array("\$insert_table","\$option","\$duplicate_detect","\$select_table","\$insert_fields","\$select_fields");
foreach ($fields as $get_field)
{
$preString = "insert_";
$field = $get_field->name;
if ($field <> "session" and $field <> "entity_id") // Exclude Defaults Fields from concatination
{
$field = "\$".$preString.$field;
} //if ($field <> "session" and $field <> "entity_id")
else
{
$field = "\$".$field;
} // else for if ($field <> "session" and $field <> "entity_id")
array_push($parameters,$field); // Push the newly generated field onto the array stack
} //foreach ($fields as $get_field)
// HERE IS WHERE IS NEED THE HELP OF SOME HOW CONVERTING THE ARRAY INTO ACTUAL VARIABLES
$get_data = $my_class-> get_my_data($parameters); // send the variables through
?>