我必须在我的网站上找到一张桌子。并且必须从以下位置获取该表的数据
””
我已经尝试了很多东西但没有任何作用......
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<?php
$json=file_get_contents("http://west.basketball.nl/db/json
/stand.pl?szn_Naam=2014-2015&cmp_ID=373");
$data = json_decode($json);
if (count($data)) {
// Open the table
echo "<table>";
// Cycle through the array
foreach ($data as $stand) {
// Output a row
echo "<tr>";
echo "<td>$afko</td>";
echo "<td>$positie</td>";
echo "</tr>";
}
// Close the table
echo "</table>";
}
?>
</body>
</html>
如果你想要递归方式:
public static function jsonToDebug($jsonText = '')
{
$arr = json_decode($jsonText, true);
$html = "";
if ($arr && is_array($arr)) {
$html .= self::_arrayToHtmlTableRecursive($arr);
}
return $html;
}
private static function _arrayToHtmlTableRecursive($arr) {
$str = "<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;
}
然后打电话echo YourClass::jsonToDebug($jsonText)
;
我的测试http://sandbox.onlinephpfunctions.com/ http://sandbox.onlinephpfunctions.com/code/0d718d0876ff24d141f451449a961081f0a48598
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)