When I echo var_dump($_variable), I get one long, wrapping line with all varable's and values like
["kt_login_user"]=> string(8) "teacher1" ["kt_login_id"]=> string(3) "973" ["kt_campusID"]=> string(4) "9088" ["kt_positionID"]=> string(1) "5"
Is there a way I can make each value display on its own line for ease of reading? Something like this:
["kt_login_user"]=> string(8) "teacher1"
["kt_login_id"]=> string(3) "973"
["kt_campusID"]=> string(4) "9088"
["kt_positionID"]=> string(1) "5"
You can press Ctrl+U to view the source code. Most Browsers will prettify the output there.
var_dump
is the ugliest way to debug.I didn't wanna stop using
var_dump($variable);die();
and usingpre
tags and loops seems overkill to me, so since I am looking at the dump in a browser, I just right click the page and choose Inspect (I use Chrome). The Elements section of the Developer Tools show the variable in a very readable format.I really love var_export(). If you like copy/paste-able code, try:
Or even something like this for color syntax highlighting:
Personally I like the replacement function provided by Symfony's var dumper component
Install with
composer require symfony/var-dumper
and just usedump($var)
It takes care of the rest. I believe there's also a bit of JS injected there to allow you to interact with the output a bit.
Wrap it in
<pre>
tags to preserve formatting.I've also researched this issue and not found the right answer. This doesn't work for me:
This will not provide a nice display of the array for me, with line breaks (I'm using Firefox 31.3.0)
However, after some experimentation, this solved the problem (notice the php is closed at first):
This solves the problem and displays a nice, easy-to-read array for me on my browser. You see how the tags are not wrapped in PHP; only the echo var_dump part is.