Super Useful PHP Helper Function

If you use PHP, especially when dealing with an API, you might want to see everything inside a variable. Normally you’d use print_r(); but that would normally return a big long line of unreadable text. Since PHP included formatting as whitespace if you wrapped the output in a <pre> tag you get a nicely indented view that is much more readable.

Here’s how you can do it super easy style, just add this function to your project:

function pretty_print($arg) {
  echo '<pre>';
  echo '</pre>';

Then you can do something like:

$var = $_SERVER;