cakephp log an array as var_dump cakephp log an array as var_dump php php

cakephp log an array as var_dump


Just use print_r, it accepts a second argument not to output the result.

CakeLog::write('debug', 'myArray'.print_r($myArray, true) );

And if you don't want new lines, tabs or double spaces in your log files:

$log = print_r($myArray, true);$log = str_replace(array("\n","\t"), " ", $log);$log = preg_replace('/\s+/', ' ',$log);CakeLog::write('debug', 'myArray' . $log);


Try:

CakeLog::write('debug', 'myArray'.print_r($myArray, true));

The true parameter makes print_r return the value rather than print on screen, so you can save it.

http://br2.php.net/manual/en/function.print-r.php


Somebody got a redirection method presented here.

This I have used to see what I have there, and it shows very clear.