blob: 6412c75fb51593159785ff8fdb73a7f16a8c4657 (
plain) (
blame)
1
2
3
4
5
6
7
8
|
#!/usr/bin/env php
<?php
class jsonHtml {
public function jsonToDebug($jsonText = ''){ $arr = json_decode($jsonText, true); $html = ""; if ($arr && is_array($arr)) { $html .= self::_arrayToHtmlTableRecursive($arr); } return $html;}
public function _arrayToHtmlTableRecursive($arr) { $str = "<style>table,td,tr,th{border:1px solid black;}</style><table><tbody>"; foreach ($arr as $key => $val) { $str .= "<tr>"; $str .= "<td>$key</td>"; $str .= "<td>"; if (is_array($val)) { if (!empty($val)) { $str .= self::_arrayToHtmlTableRecursive($val); } } else { $str .= "<strong>$val</strong>"; } $str .= "</td></tr>"; } $str .= "</tbody></table>"; return $str;}
}
file_put_contents($argv[2], jsonHtml::jsonToDebug(file_get_contents($argv[1])));
?>
|