I've spent a lot of time on this, thinking I could figure it out, but I'm royally stuck. I have a "debugging" helper function that I call when I need to know what is happening to a variable. The results of the call are inserted into a table, which I then review for problems.
Here is an earlier version of my function call to "trace_log()." It worked fine.
trace_log( file_name(__FILE__), script_name(), __FUNCTION__, __LINE__, var_name(), var_value());
Now I want to put the function call parameters into an array. Here is my code:
$myarray = array( 'myfile' => 'file_name(__FILE__)',
'script' => 'script_name()',
'func' => '__FUNCTION__',
'line' => '__LINE__',
'var_name' => 'var_name()',
'var_value' => 'var_value()'
);
Note that script_name(), var_name(), and var_value() are user defined functions.
Now, I am trying to make the parameters in $myarray work within the function, but I have not been successful. Here is how I think the code should begin:
function trace_log( $myarray )
{
/* Connect to db */
if( is_array( $myarray ) )
{
foreach( $myarray as $k => $v )
{ ... !!!!! CAN'T GET PAST THIS POINT !!!!!
Here is the code I use in the function "trace_log()" to insert the items into a table:
$sql = "INSERT
INTO reg_log_trace( step, file, script, func, line, var_name, var_value )
VALUES ( 0,'{$file}','{$script}','{$func}', {$line}, '{$var_name}', '{$var_value}' )";
How can I resolve this? Thanks for the help!