Make var_dump look pretty
To make the output of var_dump() more readable, you can use the following approaches:
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
symfony/var-dumperorxdebug, which provide more advanced formatting and analysis capabilities forvar_dump()output. - Wrap the output in an HTML
<pre>tag to preserve whitespace and indentation.
For example:
How to make var_dump look pretty in PHP?
<?php
$data = ['a', 'b', 'c'];
echo '<pre>';
var_dump($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.