A small function for exporting variables as string, supporting nested arrays, with indented output, blockquoted and with double quotes, that can be pasted back in code.
<?php
function dump($value) {
function _dump($value, $indent = 0) {
if (!is_array($value)) return json_encode($value, JSON_NUMERIC_CHECK);
foreach($value as $key => $item) $result .= (ifset($result) ? ",\r\n" . str_repeat(" ", $indent + 2) : "") . json_encode($key) . " => " . _dump($item, $indent + 2);
return "[\r\n" . str_repeat(" ", $indent + 2) . "$result\r\n" . str_repeat(" ", $indent) . "]";
}
return "<pre>" . htmlspecialchars(_dump($value)) . "</pre>";
}