W3docs

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:

  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 symfony/var-dumper or xdebug, which provide more advanced formatting and analysis capabilities for var_dump() output.
  3. 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.