Make var_dump look pretty

To make the output of var_dump() more readable, you can use the following approaches:

  1. Use a browser extension such as "PHP Var Dump Script" for Chrome, which will automatically parse and format var_dump() output in the browser.

  2. Use a third-party library such as "krumo" or "xdebug", which provide more advanced formatting and analysis capabilities for var_dump() output.

  3. Use print_r() instead of var_dump(), as it formats the output in a more readable way. You can also pass a second argument of true to print_r() to return the output as a string rather than printing it.

Watch a course Learn object oriented PHP

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.