Skip to content

Instantly share code, notes, and snippets.

@troelskn
troelskn / gist:773216
Created January 10, 2011 18:40
json_encode_pretty
<?php
/**
* Input an object, returns a json-ized string of said object, pretty-printed
*
* @param mixed $obj The array or object to encode
* @return string JSON formatted output
*/
function json_encode_pretty($obj, $indentation = 0) {
switch (gettype($obj)) {
case 'object':