'; $ind = '    '; break; default: case 'txt': $lineBreak = "\n"; //$ind = "\t"; $ind = " "; break; } // override the defined indent setting with the supplied option if (isset($options['indent'])) { $ind = $options['indent']; } $inLiteral = false; foreach ($tokens as $token) { if ($token == '') { continue; } $prefix = str_repeat($ind, $indent); if (!$inLiteral && ($token == '{' || $token == '[')) { $indent++; if (($result != '') && ($result[(strlen($result) - 1)] == $lineBreak)) { $result .= $prefix; } $result .= $token . $lineBreak; } elseif (!$inLiteral && ($token == '}' || $token == ']')) { $indent--; $prefix = str_repeat($ind, $indent); $result .= $lineBreak . $prefix . $token; } elseif (!$inLiteral && $token == ',') { $result .= $token . $lineBreak; } else { $result .= ( $inLiteral ? '' : $prefix ) . $token; // Count # of unescaped double-quotes in token, subtract # of // escaped double-quotes and if the result is odd then we are // inside a string literal if ((substr_count($token, "\"") - substr_count($token, "\\\"")) % 2 != 0) { $inLiteral = !$inLiteral; } } } return $result; } $contents = file_get_contents($reqURI); echo json_pretty($contents); ?>