![]() |
Log an Array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Log an Array (/showthread.php?tid=3059) |
Log an Array - El Forum - 09-07-2007 [eluser]tchule[/eluser] Hello, I'm constantly in need for a way to debug and log some Arrays. I'd like to log it in the log file instead of having to use a var_dump. I've added the following function to the Commun.php file of code_igniter, it works but it's probably ugly. If someone knows of a better way i'm interested ... Code: function log_array($level = 'error', $array, $php_error = FALSE) Tchule Log an Array - El Forum - 09-07-2007 [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 ( |