Welcome Guest, Not a member yet? Register   Sign In
Log an Array
#2

[eluser]Paul Scott[/eluser]
You can use var_export to simply return the structure of the array as a string, instead of using the output buffer, and then you could log that. Similarly with print_r.
So you could do something like
Code:
$my_array = array (
  0 => 1,
  1 => 2,
  2 => array (
    0 => 'a',
    1 => 'b',
    2 => 'c',
  ),
);

$log_my_error = var_export($my_array, TRUE); // Or alternatively, print_r($my_array, TRUE);

// Then you might want to put it onto one line
$log_my_error = str_replace(array("\r","\n"), '', $log_my_Error);
And now you'd have `$log_my_error` - a string containing the structure of your array.


Messages In This Thread
Log an Array - by El Forum - 09-07-2007, 07:45 AM
Log an Array - by El Forum - 09-07-2007, 07:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB