I am having a problem with returned values from a database.
In essence what I am doing is storing function information in a table
I then have a function that pulls the information to execute the function in the table such as
in the table I have
function name
parameter list
the data is returned in a string like this:
$name= "$function_name" . "|" . "$variable_string" . "|" . "$variable_count";
I then split the string into the component parts like this:
$check_q = preg_split("/[|]+/", $name);
$name = $check_q[0];
$vars = $check_q[1];
$varc = $check_q[2];
I can now echo $name(); and the stored function will execute.
The other items returned are $vars a list of parameters and $varc a count of the parameters. In the example above
$variable_string = "$PHP_AUTH_USER,$Last_Name,$First_Name";
The variable names in the string are not the values associated with the named variables but just the names of the variables. Therein lies the problem. I need to get the values of those variables (They are global on the page so the values are available) into the parameter list of
echo $name(); This also needs to be done for a varying number of parameters, and I can't hardcode the parameter list either.
It is possible to retrieve the values using preg_replace(); such as:
$data = preg_replace('/(\$AXS)/',$AXS, $data);
but I need to be able to do it like this
$data = preg_replace('/(Read name from this variable)/',(retrive the actual value of the named variable), $data);
I have two problems here, one is getting the ('/(\$AXS)/' section of the preg_replace to read the value of the variable instead of treating it like a pattern. I have tried ('/($AXS)/' and ($AXS and ("$AXS" and several other iterations and have come up empty.
The other is the ,$AXS, section I need to be able to tell it which variable I want the value for without having to write the variable name. I have thought of using an array here and use the count of parameters to build it prior to retreiving the values, but I cannot figure out how to make this work.
Anyway if you can help please let me know.
Thanks
Scott
In essence what I am doing is storing function information in a table
I then have a function that pulls the information to execute the function in the table such as
in the table I have
function name
parameter list
the data is returned in a string like this:
$name= "$function_name" . "|" . "$variable_string" . "|" . "$variable_count";
I then split the string into the component parts like this:
$check_q = preg_split("/[|]+/", $name);
$name = $check_q[0];
$vars = $check_q[1];
$varc = $check_q[2];
I can now echo $name(); and the stored function will execute.
The other items returned are $vars a list of parameters and $varc a count of the parameters. In the example above
$variable_string = "$PHP_AUTH_USER,$Last_Name,$First_Name";
The variable names in the string are not the values associated with the named variables but just the names of the variables. Therein lies the problem. I need to get the values of those variables (They are global on the page so the values are available) into the parameter list of
echo $name(); This also needs to be done for a varying number of parameters, and I can't hardcode the parameter list either.
It is possible to retrieve the values using preg_replace(); such as:
$data = preg_replace('/(\$AXS)/',$AXS, $data);
but I need to be able to do it like this
$data = preg_replace('/(Read name from this variable)/',(retrive the actual value of the named variable), $data);
I have two problems here, one is getting the ('/(\$AXS)/' section of the preg_replace to read the value of the variable instead of treating it like a pattern. I have tried ('/($AXS)/' and ($AXS and ("$AXS" and several other iterations and have come up empty.
The other is the ,$AXS, section I need to be able to tell it which variable I want the value for without having to write the variable name. I have thought of using an array here and use the count of parameters to build it prior to retreiving the values, but I cannot figure out how to make this work.
Anyway if you can help please let me know.
Thanks
Scott