How to output (to a log) a multi-level array in a format that is human-readable?

Solution 1:

If you need to log an error to Apache error log you can try this:

error_log( print_r($multidimensionalarray, TRUE) );

Solution 2:

http://php.net/manual/en/function.print-r.php This function can be used to format output,

$output = print_r($array,1);

$output is a string variable, it can be logged like every other string. In pure php you can use trigger_error

Ex. trigger_error($output);

http://php.net/manual/en/function.trigger-error.php

if you need to format it also in html, you can use <pre> tag