Make var_dump look pretty
To make the output of var_dump() more readable, you can use the following approaches:
Use a browser extension such as "PHP Var Dump Script" for Chrome, which will automatically parse and format
var_dump()output in the browser.Use a third-party library such as "krumo" or "xdebug", which provide more advanced formatting and analysis capabilities for
var_dump()output.Use
print_r()instead ofvar_dump(), as it formats the output in a more readable way. You can also pass a second argument oftruetoprint_r()to return the output as a string rather than printing it.
For example:
<?php
$data = ['a', 'b', 'c'];
echo '<pre>';
print_r($data);
echo '</pre>';This will output the array in a more readable format, with each key and value on its own line and indented appropriately.
Note: The <pre> HTML tag is used to preserve whitespace and font formatting in the output.