Make var_dump look pretty [duplicate]

I really love var_export(). If you like copy/paste-able code, try: echo ‘<pre>’ . var_export($data, true) . ‘</pre>’; Or even something like this for color syntax highlighting: highlight_string(“<?php\n\$data =\n” . var_export($data, true) . “;\n?>”); Reusable function: function highlight_array($array, $name=”var”) { highlight_string(“<?php\n\$$name =\n” . var_export($array, true) . “;\n?>”); } You can do the same with print_r(). For … Read more

Convert var_dump of array back to array variable

var_export or serialize is what you’re looking for. var_export will render a PHP parsable array syntax, and serialize will render a non-human readable but reversible “array to string” conversion… Edit Alright, for the challenge: Basically, I convert the output into a serialized string (and then unserialize it). I don’t claim this to be perfect, but … Read more