Last active
August 29, 2015 13:57
-
-
Save aurbano/9686659 to your computer and use it in GitHub Desktop.
PHP implementation of print_r to allow customization of the results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function print_json($json) { | |
if (is_array($json) || is_object($json)) { | |
echo "<table width=100%>"; | |
$type = 'Array'; | |
if(is_object($json)) $type = 'Object'; | |
echo '<tr><td colspan=2 style="background-color:#333333;"> | |
<strong><font color=white>'.$type.'</font></strong> | |
</td></tr>'; | |
foreach ($json as $k => $v) { | |
echo '<tr><td valign="top" style="background-color:#F0F0F0;">'; | |
echo '<strong>'.$k.'</strong></td><td>'; | |
print_json($v); | |
echo "</td></tr>"; | |
} | |
echo "</table>"; | |
return; | |
} | |
echo $json; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment