我使用了以下PHP代码:
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("json");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
print $output; 输出采用这样的格式:{“c讨论会结果”:{“apiversion”:2,“preevent”:{“结果”:1},“数据”:[{“mtime”:1411037171,“磁盘配额”:“无限”,"_diskused":"54“
我想把输出放在桌子上。有人能建议我怎么做吗?
发布于 2014-10-27 22:03:14
这样做有两种方法
首先解码jason到Array
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("json");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
$output = json_decode($output)
print_r($output); 第二个是在Array中获得输出,而不是jason
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("array");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
print $output; 现在您可以使用foreach循环从这个数组打印表了。
echo "<table>";
foreach ($output as $key => $value){
echo '<tr>';
echo '<td>' . $key . '</td>';
echo '<td>' . $value . '</td>';
echo '</tr>';
}
echo "</table>";https://stackoverflow.com/questions/25911272
复制相似问题